From c4a0757bb09d221eddfbe09f28859bec788dd3a7 Mon Sep 17 00:00:00 2001 From: Klaus Richarz Date: Thu, 8 Feb 2024 18:08:41 +0100 Subject: [PATCH] #294 remove change password --- .../java/org/tb/user/ShowSettingsAction.java | 70 +--------------- .../java/org/tb/user/ShowSettingsForm.java | 12 --- src/main/webapp/user/showSettings.jsp | 84 +------------------ 3 files changed, 2 insertions(+), 164 deletions(-) diff --git a/src/main/java/org/tb/user/ShowSettingsAction.java b/src/main/java/org/tb/user/ShowSettingsAction.java index 15471f87c..fb5842cb4 100644 --- a/src/main/java/org/tb/user/ShowSettingsAction.java +++ b/src/main/java/org/tb/user/ShowSettingsAction.java @@ -5,13 +5,8 @@ import lombok.RequiredArgsConstructor; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; import org.springframework.stereotype.Component; -import org.tb.common.GlobalConstants; import org.tb.common.struts.LoginRequiredAction; -import org.tb.common.util.SecureHashUtils; -import org.tb.employee.domain.Employee; import org.tb.employee.persistence.EmployeeDAO; @Component @@ -27,71 +22,8 @@ protected ActionForward executeAuthenticated(ActionMapping mapping, ShowSettingsForm settingsForm, HttpServletRequest request, HttpServletResponse response) throws Exception { - request.setAttribute("passwordchanged", false); request.setAttribute("userAccessTokens", userAccessTokenService.getTokens(authorizedUser.getEmployeeId())); - - if ("changePassword".equalsIgnoreCase(request.getParameter("task"))) { - ActionMessages errorMessages = validatePassword(request, settingsForm); - if (!errorMessages.isEmpty()) { - return mapping.getInputForward(); - } - - // get employee - Employee loginEmployee = (Employee) request.getSession().getAttribute("loginEmployee"); - - // set new password and save - if(userService.changePassword(loginEmployee.getId(), settingsForm.getNewpassword())) { - request.setAttribute("passwordchanged", true); - return mapping.findForward("success"); - } else { - ActionMessages messages = new ActionMessages(); - messages.add("newpassword", new ActionMessage("form.settings.error.newpassword.violates.rules")); - saveErrors(request, messages); - return mapping.getInputForward(); - } - } else { - // task == null -> standard procedure - return mapping.findForward("success"); - } - } - - private ActionMessages validatePassword(HttpServletRequest request, - ShowSettingsForm settingsForm) { - - ActionMessages errors = getErrors(request); - if (errors == null) errors = new ActionMessages(); - - String oldPassword = settingsForm.getOldpassword(); - String newPassword = settingsForm.getNewpassword(); - String confirmPassword = settingsForm.getConfirmpassword(); - - //old password - Employee loginEmployee = (Employee) request.getSession().getAttribute("loginEmployee"); - String passwordFromDB = employeeDAO.getEmployeeById(loginEmployee.getId()).getPassword(); - if (oldPassword == null || !SecureHashUtils.passwordMatches(oldPassword, passwordFromDB)) { - errors.add("oldpassword", new ActionMessage("form.settings.error.oldpassword.false")); - } - - // new password - if (newPassword == null || newPassword.length() < GlobalConstants.EMPLOYEE_PASSWORD_MIN_LENGTH) { - // new password is missing or too short - errors.add("newpassword", new ActionMessage("form.settings.error.newpassword.tooshort")); - } else if (newPassword.length() > GlobalConstants.EMPLOYEE_PASSWORD_MAX_LENGTH) { - // new password is too long - errors.add("newpassword", new ActionMessage("form.settings.error.newpassword.toolong")); - } - - // confirm new password - if (confirmPassword == null) { - // confirm password is missing - errors.add("confirmpassword", new ActionMessage("form.settings.error.confirmpassword.missing")); - } else if (!confirmPassword.equals(newPassword)) { - // confirm password does not match with new password - errors.add("confirmpassword", new ActionMessage("form.settings.error.confirmpassword.false")); - } - - saveErrors(request, errors); - return errors; + return mapping.findForward("success"); } @Override diff --git a/src/main/java/org/tb/user/ShowSettingsForm.java b/src/main/java/org/tb/user/ShowSettingsForm.java index dbfcc2fe1..aae6afd5d 100644 --- a/src/main/java/org/tb/user/ShowSettingsForm.java +++ b/src/main/java/org/tb/user/ShowSettingsForm.java @@ -10,16 +10,4 @@ @Setter public class ShowSettingsForm extends ActionForm { private static final long serialVersionUID = 1L; // 4564667507077065751L; - - private String oldpassword; - private String newpassword; - private String confirmpassword; - - @Override - public void reset(ActionMapping mapping, HttpServletRequest request) { - oldpassword = ""; - newpassword = ""; - confirmpassword = ""; - } - } diff --git a/src/main/webapp/user/showSettings.jsp b/src/main/webapp/user/showSettings.jsp index e70da0475..e971196d4 100644 --- a/src/main/webapp/user/showSettings.jsp +++ b/src/main/webapp/user/showSettings.jsp @@ -5,14 +5,8 @@ <bean:message key="main.general.application.title" /> - - <bean:message key="main.general.mainmenu.settings.title.text" /> + - @@ -23,82 +17,6 @@ :

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

-

-
-
-
-   
-   
-   
-   
-
 
:
: -
: -

-
-
- - - - -
- -
-