use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UsersServiceFacadeImpl method assertPasswordResetOperationValid.
protected String assertPasswordResetOperationValid(String email, String passwordResetToken, PasswordReset resetPasswordRequest) throws FieldValidationException, UserNotFoundException, GenericException {
validatePasswordReset(resetPasswordRequest);
try {
validateUserIsEligableForPasswordReset(email);
} catch (FieldValidationException fve) {
throw new GenericException(CommonMessageCodes.ERROR_UNEXPECTED, fve);
}
User user = userService.getUserByEmail(email);
String userUuid = user.getUuid();
boolean isValid = passwordService.isRestorationTokenValid(userUuid, passwordResetToken);
if (!isValid) {
throw new GenericException(SecurityMessageCodes.INVALID_PASSWORD_RESET_TOKEN);
}
return userUuid;
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UsersServiceFacadeImpl method runUserRegisteredHandler.
protected void runUserRegisteredHandler(final User user) {
if (userRegisteredHandler == null) {
return;
}
List<String> perms = permissionService.findUserPermissionsForSubject(SecurityConstants.DOMAIN, user.getUuid(), null);
ElevationRunnerImpl runAs = new ElevationRunnerImpl(new ElevationStrategyRunAsUserImpl<User>(user, perms));
runAs.runElevated(new Runnable() {
@Override
public void run() {
userRegisteredHandler.onUserRegistered(user);
}
});
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UsersServiceFacadeImpl method changePassword.
@Override
public void changePassword(String email, PasswordChange passwordChange) throws UserNotFoundException, FieldValidationException {
try {
User user = validatePasswordChangeRequestValid(email, passwordChange);
passwordService.setUserPassword(user.getUuid(), passwordChange.getPassword());
} catch (Throwable e) {
Throwables.throwIfInstanceOf(e, FieldValidationException.class);
throw new UserServiceUnexpectedException("Failed to arrange password reset", e);
}
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testCreateUser_blackbox_expectValidationExceptionOnInvalidEmail1.
@Test(expected = FieldValidationException.class)
public void testCreateUser_blackbox_expectValidationExceptionOnInvalidEmail1() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createNewUserTemplate();
user.setEmail(null);
fixture.createUser(user);
fail();
}
use of org.summerb.microservices.users.api.dto.User in project summerb by skarpushin.
the class UserServiceImplTest method testUpdateUser_blackbox_fveOnFailedValidation.
@Test(expected = FieldValidationException.class)
public void testUpdateUser_blackbox_fveOnFailedValidation() throws Exception {
UserServiceImpl fixture = UserServiceImplFactory.createUsersServiceImpl();
User user = UserFactory.createExistingUser();
user.setEmail("asdasd");
when(fixture.getUserDao().updateUser(any(User.class))).thenReturn(true);
fixture.updateUser(user);
fail();
}
Aggregations