Updated create user validation
This commit is contained in:
@@ -232,6 +232,6 @@ public class GepafinConstant {
|
||||
public static final String GET_LOGIN_ATTEMPT_MSG="get_login_attempt_se_msg";
|
||||
public static final String CANNOT_DELETE_COMPANY_WITH_APPLICATION_SUBMITT = "application.in.submit.status.cannot.delete.company";
|
||||
public static final String GET_USERS_SUCCESS_MSG = "get.users.success.msg";
|
||||
|
||||
public static final String CANNOT_CREATE_BENEFICIARY_USER="cannot.create.beneficiary.user";
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public class UserDao {
|
||||
|
||||
|
||||
public JWTToken createUser(HttpServletRequest request, String tempToken, UserReq userReq) {
|
||||
|
||||
validateUserRequest(tempToken, userReq);
|
||||
validatePassword(userReq.getPassword(), userReq.getConfPassword(), tempToken);
|
||||
|
||||
@@ -99,6 +100,7 @@ public class UserDao {
|
||||
}
|
||||
|
||||
private void validateUserRequest(String tempToken, UserReq userReq) {
|
||||
RoleEntity role = roleService.validateRole(userReq.getRoleId());
|
||||
if (Boolean.FALSE.equals(Utils.isValidEmail(userReq.getEmail()))) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.VALIDATE_EMAIL));
|
||||
@@ -122,6 +124,10 @@ public class UserDao {
|
||||
if (tempToken != null) {
|
||||
userReq.setRoleId(null);
|
||||
}
|
||||
if(tempToken == null && Boolean.TRUE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(role.getRoleType()))){
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CANNOT_CREATE_BENEFICIARY_USER));
|
||||
}
|
||||
}
|
||||
|
||||
private void validatePassword(String password, String confirmPassword, String tempToken) {
|
||||
|
||||
@@ -252,4 +252,7 @@ login_attempt_successfully_created = Login attempt successfully created.
|
||||
get_login_attempt_se_msg=Login attempts fetched successfully.
|
||||
application.in.submit.status.cannot.delete.company=The company cannot be deleted because there are active applications in the SUBMITTED status.
|
||||
get.users.success.msg = Successfully fetched users.
|
||||
cannot.create.beneficiary.user = Creation of a Beneficiary user is not allowed. Please assign the appropriate role.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -248,4 +248,6 @@ login_attempt_successfully_created= Tentativo di login creato con successo.
|
||||
get_login_attempt_se_msg=Lista dei tentativi di accesso recuperata correttamente.
|
||||
application.in.submit.status.cannot.delete.company=Non è possibile eliminare l'azienda perché ci sono domande attive con stato SUBMITTED.
|
||||
|
||||
get.users.success.msg = Utenti recuperati con successo
|
||||
get.users.success.msg = Utenti recuperati con successo
|
||||
cannot.create.beneficiary.user = La creazione di un utente beneficiario non è consentita. Si prega di assegnare il ruolo appropriato.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user