allow the user to change their password
This commit is contained in:
@ -284,6 +284,14 @@ public class BlogManager {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean changePasswrd(User user, String oldPass, String pass0, String pass1) {
|
||||
boolean ok = user.changePassword(oldPass, pass0, pass1);
|
||||
if (ok)
|
||||
saveUser(user);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
public User login(String login, String pass) {
|
||||
User u = new User(_context);
|
||||
String ok = login(u, login, pass);
|
||||
@ -438,7 +446,7 @@ public class BlogManager {
|
||||
private static final String PROP_DEFAULT_LOGIN = "syndie.defaultSingleUserLogin";
|
||||
private static final String PROP_DEFAULT_PASS = "syndie.defaultSingleUserPass";
|
||||
|
||||
private String getDefaultLogin() {
|
||||
public String getDefaultLogin() {
|
||||
String login = _context.getProperty(PROP_DEFAULT_LOGIN);
|
||||
if ( (login == null) || (login.trim().length() <= 0) )
|
||||
login = DEFAULT_LOGIN;
|
||||
|
@ -319,6 +319,14 @@ public abstract class BaseServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
String pass0 = req.getParameter("password");
|
||||
String pass1 = req.getParameter("passwordConfirm");
|
||||
String oldPass = req.getParameter("oldPassword");
|
||||
|
||||
if ( (pass0 != null) && (pass1 != null) && (pass0.equals(pass1)) ) {
|
||||
BlogManager.instance().changePasswrd(user, oldPass, pass0, pass1);
|
||||
}
|
||||
|
||||
boolean updated = BlogManager.instance().updateMetadata(user, user.getBlog(), opts);
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,16 @@ public class ProfileServlet extends BaseServlet {
|
||||
}
|
||||
out.write("</textarea></td></tr>\n");
|
||||
|
||||
if (user.getAuthenticated()) {
|
||||
if ( (user.getUsername() == null) || (user.getUsername().equals(BlogManager.instance().getDefaultLogin())) ) {
|
||||
// this is the default user, don't let them change the password
|
||||
} else {
|
||||
out.write("<tr><td colspan=\"3\">Old Password: <input type=\"password\" name=\"oldPassword\" /></td></tr>\n");
|
||||
out.write("<tr><td colspan=\"3\">Password: <input type=\"password\" name=\"password\" /></td></tr>\n");
|
||||
out.write("<tr><td colspan=\"3\">Password again: <input type=\"password\" name=\"passwordConfirm\" /></td></tr>\n");
|
||||
}
|
||||
}
|
||||
|
||||
out.write("<tr><td colspan=\"3\"><input type=\"submit\" name=\"action\" value=\"Update profile\" /></td></tr>\n");
|
||||
out.write("</form>\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user