Created
January 28, 2012 03:41
-
-
Save andresamayadiaz/1692460 to your computer and use it in GitHub Desktop.
Play Password Change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void update(User entity, String repassword, boolean chgPassword) { | |
Gson gson = new Gson(); | |
Logger.info("ENTITY 1: "+gson.toJson(entity)); | |
// Validate Password Change | |
if(chgPassword){ | |
if(!entity.password.equals(repassword)){ | |
validation.addError("repassword", "Password does not match!"); | |
render("@edit", entity); | |
} | |
if(entity.password.equals("")){ | |
validation.addError("entity.password", "Password cannot be empty!"); | |
render("@edit", entity); | |
} | |
}else { | |
User usr = User.findById(entity.id); | |
Logger.info("USER: "+gson.toJson(usr)); | |
Logger.info("ENTITY 2: "+gson.toJson(entity)); | |
//Logger.info("ID: [%s] - Set same password = %s", entity.id, usr.password); | |
entity.password = usr.password; | |
} | |
validation.valid(entity); | |
if (validation.hasErrors()) { | |
render("@edit", entity); | |
} | |
entity = entity.merge(); | |
entity.save(); | |
flash.success(Messages.get("user.updated", "User")); | |
index(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the Output:
21:45:44,098 INFO ~ EDIT ENTITY: {"userName":"[email protected]","fullName":"Jorge Lopez Perez","password":"123","isAdmin":true,"id":3}
21:45:53,701 INFO ~ ENTITY 1: {"userName":"[email protected]","fullName":"Jorge Lopez","password":"","isAdmin":true,"id":3}
21:45:53,702 INFO ~ USER: {"userName":"[email protected]","fullName":"Jorge Lopez","password":"","isAdmin":true,"id":3}
21:45:53,702 INFO ~ ENTITY 2: {"userName":"[email protected]","fullName":"Jorge Lopez","password":"","isAdmin":true,"id":3}
The EDIT ENTITY is the User info when i enter the edit method