From 4c49c77641e0910c047278842703c10fc3aadcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cocula?= Date: Thu, 5 Jan 2017 23:23:47 +0100 Subject: [PATCH] Restore PasswordSettingsController --- .../command/PasswordSettingsCommand.java | 8 ------ .../PasswordSettingsController.java | 27 ++++++++----------- .../webapp/WEB-INF/jsp/passwordSettings.jsp | 1 + 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/PasswordSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/PasswordSettingsCommand.java index 8f12e554..fe9664b5 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/PasswordSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/PasswordSettingsCommand.java @@ -31,7 +31,6 @@ public class PasswordSettingsCommand { private String password; private String confirmPassword; private boolean ldapAuthenticated; - private boolean toast; public String getUsername() { return username; @@ -65,11 +64,4 @@ public class PasswordSettingsCommand { this.ldapAuthenticated = ldapAuthenticated; } - public boolean isToast() { - return toast; - } - - public void setToast(boolean toast) { - this.toast = toast; - } } \ No newline at end of file diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/PasswordSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/PasswordSettingsController.java index 63f0504b..003792f6 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/PasswordSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/PasswordSettingsController.java @@ -43,7 +43,7 @@ import javax.servlet.http.*; */ @org.springframework.stereotype.Controller @RequestMapping("/passwordSettings") -@SessionAttributes( value="command", types={PasswordSettingsCommand.class} ) +//@SessionAttributes( value="command", types={PasswordSettingsCommand.class} ) public class PasswordSettingsController { @Autowired @@ -56,14 +56,6 @@ public class PasswordSettingsController { binder.addValidators(passwordSettingsValidator); } - /* @ModelAttribute - protected Object formBackingObject(HttpServletRequest request) throws Exception { - PasswordSettingsCommand command = new PasswordSettingsCommand(); - User user = securityService.getCurrentUser(request); - command.setUsername(user.getUsername()); - command.setLdapAuthenticated(user.isLdapAuthenticated()); - return command; - }*/ @RequestMapping(method = RequestMethod.GET) protected ModelAndView displayForm(HttpServletRequest request) throws Exception { @@ -75,14 +67,17 @@ public class PasswordSettingsController { } @RequestMapping(method = RequestMethod.POST) - protected String doSubmitAction(@ModelAttribute("command") @Validated PasswordSettingsCommand command) throws Exception { - User user = securityService.getUserByName(command.getUsername()); - user.setPassword(command.getPassword()); - securityService.updateUser(user); + protected String doSubmitAction(HttpServletRequest request,@ModelAttribute("command") @Validated PasswordSettingsCommand command,BindingResult bindingResult) throws Exception { + if (!bindingResult.hasErrors()) { + User user = securityService.getUserByName(command.getUsername()); + user.setPassword(command.getPassword()); + securityService.updateUser(user); + + command.setPassword(null); + command.setConfirmPassword(null); + request.setAttribute("settings_toast",true); - command.setPassword(null); - command.setConfirmPassword(null); - command.setToast(true); + } return "passwordSettings"; } diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp index b7010c03..e63f9842 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp @@ -23,6 +23,7 @@ ${command.username}

${fn:escapeXml(title)}

+