Restore PasswordSettingsController

master
Rémi Cocula 8 years ago
parent 884826b3b8
commit 4c49c77641
  1. 8
      libresonic-main/src/main/java/org/libresonic/player/command/PasswordSettingsCommand.java
  2. 27
      libresonic-main/src/main/java/org/libresonic/player/controller/PasswordSettingsController.java
  3. 1
      libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp

@ -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;
}
}

@ -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";
}

@ -23,6 +23,7 @@
<fmt:message key="passwordsettings.title" var="title"><fmt:param>${command.username}</fmt:param></fmt:message>
<h2>${fn:escapeXml(title)}</h2>
<form:form method="post" action="passwordSettings.view" commandName="command">
<form:hidden path="username"/>
<table class="indent">
<tr>
<td><fmt:message key="usersettings.newpassword"/></td>

Loading…
Cancel
Save