use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class UsersServiceFacadeImpl method getNewPasswordResetToken.
@Transactional(rollbackFor = Throwable.class)
@Override
public String getNewPasswordResetToken(String email) throws FieldValidationException {
try {
validateUserIsEligableForPasswordReset(email);
User user = userService.getUserByEmail(email);
String passwordResetToken = passwordService.getNewRestorationTokenForUser(user.getUuid());
if (passwordResetArmedHandler != null) {
passwordResetArmedHandler.onPasswordResetRequested(user, passwordResetToken);
}
return passwordResetToken;
} catch (Throwable e) {
Throwables.throwIfInstanceOf(e, FieldValidationException.class);
throw new UserServiceUnexpectedException("Failed to arrange password reset", e);
}
}
use of org.summerb.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.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.users.api.dto.User in project summerb by skarpushin.
the class LocaleResolverUserBasedImpl method updateUserProfileWithNewLocale.
private void updateUserProfileWithNewLocale(String newLocale) throws UserNotFoundException, FieldValidationException {
User user = securityContextResolver.getUser();
if (user.getLocale().equalsIgnoreCase(newLocale)) {
return;
}
user.setLocale(newLocale);
userService.updateUser(user);
}
use of org.summerb.users.api.dto.User in project summerb by skarpushin.
the class LocaleResolverUserBasedImpl method resolveLocale.
@Override
public Locale resolveLocale(HttpServletRequest request) {
try {
boolean isRegisteredUser = securityContextResolver.hasRole(SecurityConstants.ROLE_USER);
if (isRegisteredUser) {
User user = securityContextResolver.getUser();
Locale userLocale = StringUtils.parseLocaleString(user.getLocale());
return userLocale;
}
} catch (Throwable t) {
log.warn("Failed to resolve locale based on user data", t);
}
return super.resolveLocale(request);
}
Aggregations