Package com.dzidzi.api
Interface CredentialApi
public interface CredentialApi
CredentialApi contains all the api operations for handling
Credential of the DzidziApp.
The credential api is the most important of the DzidziApp. This api is used to create the necessary users in the DzidziApp.
-
Method Summary
Modifier and TypeMethodDescriptionaddNewPassword(CreateNewPasswordRequest createNewPasswordRequest, String verificationCode) The new password and username to complete credential account creation.addNewUserCredentialByAdmin(String email, UserRole role) Creates a user credential.changeUserPassword(String oldPass, String newPass, String username, UUID credentialId) Changes the existing password of the user.voiddeactivateUserAccount(UUID credentialId) Deactivates account by admin if user is a courier, admin, restaurant, user and service.voiddeactivateUserAccountByAdmin(String email, UserRole role) Deactivates account by admin.Finds the list of credentials and sort them by username in asc.findCredentialsByCredentialIds(List<UUID> credentialIds) Finds a list of credentials by the given credential idsfindUserCredentialById(UUID credentialId) Finds the user credential by id.findUserCredentialByVerificationCode(String verificationCode) Finds the credential by verification code.com.dzidzi.service.login.DzidziUserDetailsgetUserDetails(String username) com.dzidzi.service.login.DzidziUserDetailsgetUserDetails(String email, UserRole role) voidpasswordResetLink(String emailOrUsername, UserRole userRole) This generates a new password reset link for the given username or email and role.voidreactivateUserAccountByAdmin(UUID userId) Admin reactivates account that has been deactivated.voidremoveUserAccount(UUID credentialId) Removes the account from the system.voidresetPassword(String password, String repeatedPassword, String passwordChangeCode) Sets a new user account password with the given password.booleanusernameExist(String username)
-
Method Details
-
findUserCredentialById
Finds the user credential by id.- Parameters:
credentialId- the id of the user credential- Returns:
- the credential found
- Throws:
com.dzidzi.exception.EntityNotFoundException- when credential is not found
-
findCredentialsByCredentialIds
Finds a list of credentials by the given credential ids- Parameters:
credentialIds- list of credential ids- Returns:
- list of credentials
- Throws:
com.dzidzi.exception.EntityNotFoundException- when credential is not found
-
findAllUsersCredentials
List<Credential> findAllUsersCredentials()Finds the list of credentials and sort them by username in asc.- Returns:
- the list of credentials
-
addNewUserCredentialByAdmin
Creates a user credential. This is created upon approval of the admin that is admin creates these users withUserRole.ADMIN,UserRole.SERVICE,UserRole.COURIER,UserRole.RESTAURANT_ADMIN. OnlyUserRole.ADMINcan access this method.- Parameters:
email- the email of the new user.role- theUserRoleof the user ie RESTAURANT, ADMIN, COURIER OR SERVICE- Returns:
- the
Credentialof the new user. - Throws:
com.dzidzi.exception.DzidziException- when email already exists for the roles other thanUserRole.COURIER. One email can only have two roles that is onlyUserRole.USERandUserRole.COURIER.
-
findUserCredentialByVerificationCode
Finds the credential by verification code.- Parameters:
verificationCode- the verification code of the user- Returns:
- the credential found
- Throws:
com.dzidzi.exception.EntityNotFoundException- when entity is not found
-
changeUserPassword
Changes the existing password of the user.- Parameters:
oldPass- the existing passwordnewPass- the new passwordusername- the usernamecredentialId- credential id- Returns:
- the updated credential
- Throws:
com.dzidzi.exception.DzidziException- when old password does not match password in the DB
-
passwordResetLink
This generates a new password reset link for the given username or email and role. This link expires in 10min.- Parameters:
emailOrUsername- the email or username of useruserRole- the user role- Throws:
com.dzidzi.exception.EntityNotFoundException- when the username or email doesn't existcom.dzidzi.exception.DzidziException- when the user signed up with a third party.
-
addNewPassword
Credential addNewPassword(CreateNewPasswordRequest createNewPasswordRequest, String verificationCode) The new password and username to complete credential account creation.- Parameters:
createNewPasswordRequest- theCreateNewPasswordRequestto complete creating an accountverificationCode- the verification code of the user credential- Returns:
- the newly activated credential.
- Throws:
com.dzidzi.exception.DzidziException- when repeated password does not match new password
-
removeUserAccount
Removes the account from the system.- Parameters:
credentialId- credential id
-
resetPassword
Sets a new user account password with the given password.- Parameters:
password- the new password to userepeatedPassword- the repeated passwordpasswordChangeCode- the password change hashed code
-
deactivateUserAccountByAdmin
Deactivates account by admin. Roles that can be deactivated by admin are service, restaurant, courier and admin.- Parameters:
email- the user emailrole- the role
-
deactivateUserAccount
Deactivates account by admin if user is a courier, admin, restaurant, user and service. Only users with USER roles can deactivate themselves.- Parameters:
credentialId- the user id
-
reactivateUserAccountByAdmin
Admin reactivates account that has been deactivated. Roles that can be reactivated by admin are service, restaurant, courier and admin.- Parameters:
userId- the id of the service, courier, restaurant or admin
-
getCurrentUserCredential
Credential getCurrentUserCredential() -
usernameExist
-
getUserDetails
-
getUserDetails
-