use of org.codenergic.theskeleton.tokenstore.TokenStoreRestData in project theskeleton by codenergic.
the class RegistrationServiceImpl method changePassword.
@Override
@Transactional
public void changePassword(String activationToken, String password) {
try {
TokenStoreRestData token = tokenStoreService.findAndVerifyToken(activationToken);
if (token.isExpired()) {
throw new RegistrationException("Key is Expired");
}
UserEntity user = (UserEntity) token.getUser();
user.setPassword(passwordEncoder.encode(password));
} catch (InvalidSignatureException e) {
throw new RegistrationException("Invalid Token");
}
}
use of org.codenergic.theskeleton.tokenstore.TokenStoreRestData in project theskeleton by codenergic.
the class RegistrationServiceImpl method activateUser.
@Override
@Transactional
public void activateUser(String activationToken) {
try {
TokenStoreRestData token = tokenStoreService.findAndVerifyToken(activationToken);
UserEntity user = (UserEntity) token.getUser();
if (user.isEnabled()) {
throw new RegistrationException("Your Account is already activated");
}
user.setEnabled(true);
} catch (InvalidSignatureException e) {
throw new RegistrationException("Invalid Activation Key");
}
}
use of org.codenergic.theskeleton.tokenstore.TokenStoreRestData in project theskeleton by codenergic.
the class ChangePasswordController method updateView.
@GetMapping(path = "/update")
public String updateView(@RequestParam(name = "rt") String resetToken, UpdatePasswordForm updatePasswordForm) {
try {
TokenStoreRestData token = tokenStoreService.findAndVerifyToken(resetToken);
updatePasswordForm.setToken(token.getSignedToken());
return CHANGEPASS_UPDATE;
} catch (InvalidSignatureException e) {
return "redirect:/changepass";
}
}
Aggregations