Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import lombok.extern.slf4j.Slf4j;

/**
* The UserActionController handles non-API, non-Page requests like token validation links from emails.
* The UserActionController handles non-API, non-Page requests like token
* validation links from emails.
*/
@Slf4j
@RequiredArgsConstructor
Expand Down Expand Up @@ -56,20 +57,23 @@ public class UserActionController {
private String forgotPasswordChangeURI;

/**
* Validate a forgot password token link from an email, and if valid, show the change password page.
* Validate a forgot password token link from an email, and if valid, show the
* change password page.
*
* @param request the request
* @param model the model
* @param token the token
* @param model the model
* @param token the token
* @return the model and view
*/
@GetMapping("/user/changePassword")
public ModelAndView showChangePasswordPage(final HttpServletRequest request, final ModelMap model, @RequestParam("token") final String token) {
@GetMapping("${user.security.changePasswordURI:/user/changePassword}")
public ModelAndView showChangePasswordPage(final HttpServletRequest request, final ModelMap model,
@RequestParam("token") final String token) {
log.debug("UserAPI.showChangePasswordPage: called with token: {}", token);
final TokenValidationResult result = userService.validatePasswordResetToken(token);
log.debug("UserAPI.showChangePasswordPage:" + "result: {}", result);
AuditEvent changePasswordAuditEvent = AuditEvent.builder().source(this).sessionId(request.getSession().getId())
.ipAddress(UserUtils.getClientIP(request)).userAgent(request.getHeader("User-Agent")).action("showChangePasswordPage")
.ipAddress(UserUtils.getClientIP(request)).userAgent(request.getHeader("User-Agent"))
.action("showChangePasswordPage")
.actionStatus("Success").message("Requested. Result:" + result).build();

eventPublisher.publishEvent(changePasswordAuditEvent);
Expand All @@ -85,15 +89,16 @@ public ModelAndView showChangePasswordPage(final HttpServletRequest request, fin
}

/**
* Validate a forgot password token link from an email, and if valid, show the registration success page.
* Validate a forgot password token link from an email, and if valid, show the
* registration success page.
*
* @param request the request
* @param model the model
* @param token the token
* @param model the model
* @param token the token
* @return the model and view
* @throws UnsupportedEncodingException the unsupported encoding exception
*/
@GetMapping("/user/registrationConfirm")
@GetMapping("${user.security.registrationConfirmURI:/user/registrationConfirm}")
public ModelAndView confirmRegistration(final HttpServletRequest request, final ModelMap model,
@RequestParam("token") final String token) throws UnsupportedEncodingException {
log.debug("UserAPI.confirmRegistration: called with token: {}", token);
Expand All @@ -107,8 +112,10 @@ public ModelAndView confirmRegistration(final HttpServletRequest request, final
userService.authWithoutPassword(user);
userVerificationService.deleteVerificationToken(token);

AuditEvent registrationAuditEvent = AuditEvent.builder().source(this).user(user).sessionId(request.getSession().getId())
.ipAddress(UserUtils.getClientIP(request)).userAgent(request.getHeader("User-Agent")).action("Registration Confirmation")
AuditEvent registrationAuditEvent = AuditEvent.builder().source(this).user(user)
.sessionId(request.getSession().getId())
.ipAddress(UserUtils.getClientIP(request)).userAgent(request.getHeader("User-Agent"))
.action("Registration Confirmation")
.actionStatus("Success").message("Registration Confirmed. User logged in.").build();

eventPublisher.publishEvent(registrationAuditEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public class UserPageController {
* Login Page.
*
* @param userDetails the user details
* @param session the session
* @param model the model
* @param session the session
* @param model the model
*
* @return the string
*/
@GetMapping("/user/login.html")
@GetMapping("${user.security.loginPageURI:/user/login.html}")
public String login(@AuthenticationPrincipal DSUserDetails userDetails, HttpSession session, ModelMap model) {
log.debug("UserPageController.login:" + "userDetails: {}", userDetails);
if (session != null && session.getAttribute("error.message") != null) {
Expand All @@ -52,11 +52,11 @@ public String login(@AuthenticationPrincipal DSUserDetails userDetails, HttpSess
* Register Page.
*
* @param userDetails the user details
* @param session the session
* @param model the model
* @param session the session
* @param model the model
* @return the string
*/
@GetMapping("/user/register.html")
@GetMapping("${user.security.registrationURI:/user/register.html}")
public String register(@AuthenticationPrincipal DSUserDetails userDetails, HttpSession session, ModelMap model) {
log.debug("UserPageController.register:" + "userDetails: {}", userDetails);
if (session != null && session.getAttribute("error.message") != null) {
Expand All @@ -73,7 +73,7 @@ public String register(@AuthenticationPrincipal DSUserDetails userDetails, HttpS
*
* @return the string
*/
@GetMapping("/user/registration-pending-verification.html")
@GetMapping("${user.security.registrationPendingURI:/user/registration-pending-verification.html}")
public String registrationPending() {
return "user/registration-pending-verification";
}
Expand All @@ -82,13 +82,14 @@ public String registrationPending() {
* Registration complete.
*
* @param userDetails the user details
* @param session the session
* @param model the model
* @param session the session
* @param model the model
*
* @return the string
*/
@GetMapping("/user/registration-complete.html")
public String registrationComplete(@AuthenticationPrincipal DSUserDetails userDetails, HttpSession session, ModelMap model) {
@GetMapping("${user.security.registrationSuccessURI:/user/registration-complete.html}")
public String registrationComplete(@AuthenticationPrincipal DSUserDetails userDetails, HttpSession session,
ModelMap model) {
log.debug("UserPageController.registrationComplete:" + "userDetails: {}", userDetails);
return "user/registration-complete";
}
Expand All @@ -98,7 +99,7 @@ public String registrationComplete(@AuthenticationPrincipal DSUserDetails userDe
*
* @return the string
*/
@GetMapping("/user/request-new-verification-email.html")
@GetMapping("${user.security.registrationNewVerificationURI:/user/request-new-verification-email.html}")
public String requestNewVerificationEMail() {
return "user/request-new-verification-email";
}
Expand All @@ -108,7 +109,7 @@ public String requestNewVerificationEMail() {
*
* @return the string
*/
@GetMapping("/user/forgot-password.html")
@GetMapping("${user.security.forgotPasswordURI:/user/forgot-password.html}")
public String forgotPassword() {
return "user/forgot-password";
}
Expand All @@ -118,7 +119,7 @@ public String forgotPassword() {
*
* @return the string
*/
@GetMapping("/user/forgot-password-pending-verification.html")
@GetMapping("${user.security.forgotPasswordPendingURI:/user/forgot-password-pending-verification.html}")
public String forgotPasswordPendingVerification() {
return "user/forgot-password-pending-verification";
}
Expand All @@ -128,20 +129,20 @@ public String forgotPasswordPendingVerification() {
*
* @return the string
*/
@GetMapping("/user/forgot-password-change.html")
@GetMapping("${user.security.forgotPasswordChangeURI:/user/forgot-password-change.html}")
public String forgotPasswordChange() {
return "user/forgot-password-change";
}


/**
* @param userDetails the user details
* @param request the request
* @param model the model
* @param request the request
* @param model the model
* @return String
*/
@GetMapping("/user/update-user.html")
public String updateUser(@AuthenticationPrincipal DSUserDetails userDetails, final HttpServletRequest request, final ModelMap model) {
@GetMapping("${user.security.updateUserURI:/user/update-user.html}")
public String updateUser(@AuthenticationPrincipal DSUserDetails userDetails, final HttpServletRequest request,
final ModelMap model) {
if (userDetails != null) {
User user = userDetails.getUser();
UserDto userDto = new UserDto();
Expand All @@ -157,7 +158,7 @@ public String updateUser(@AuthenticationPrincipal DSUserDetails userDetails, fin
*
* @return the string
*/
@GetMapping("/user/update-password.html")
@GetMapping("${user.security.updatePasswordURI:/user/update-password.html}")
public String updatePassword() {
return "user/update-password";
}
Expand All @@ -167,7 +168,7 @@ public String updatePassword() {
*
* @return the string
*/
@GetMapping("/user/delete-account.html")
@GetMapping("${user.security.deleteAccountURI:/user/delete-account.html}")
public String deleteAccount() {
return "user/delete-account";
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/config/dsspringuserconfig.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ user.security.registrationSuccessURI=/user/registration-complete.html
user.security.registrationNewVerificationURI=/user/request-new-verification-email.html
# The URI for the update user page.
user.security.updateUserURI=/user/update-user.html
# The URI for the update password page.
user.security.updatePasswordURI=/user/update-password.html
# The URI for the delete account page.
user.security.deleteAccountURI=/user/delete-account.html
# The URI for the change password page.
user.security.changePasswordURI=/user/changePassword
# The URI for the registration confirm page.
user.security.registrationConfirmURI=/user/registrationConfirm

# The from address for all emails sent by the application.
user.mail.fromAddress=test@test.com
Expand Down