日期:2014-05-16 浏览次数:20342 次
var pwdArray = [];
$(".yellow_btn input").click(function(){
$("input[type=password]").each(function(){
pwdArray.push($(this).val());
});
var oldPwd = pwdArray[0];
var newPwd = pwdArray[1];
$.post( $.frontPath + "updatePassword.json",{newPassword:newPwd,oldPassword:oldPwd},function(data){
$.refresh($.frontPath + "personal/safeOk");
});
});
@RequestMapping(value="updatePassword.json")
public Map<String, Object> updatePasswprd(ModelMap map , String newPassword , String oldPassword ){
long userId = this.getFrontUserId();
if(userId == Global.NULL_ID)
return this.createJSONError("no login");
boolean isMatch = false;
boolean isUpdate = false;
if( oldPassword != null && oldPassword.length() > 0 ){
isMatch = this.userService.checkPassword(oldPassword, userId);
if( isMatch && newPassword != null && newPassword.length() > 0 ){
isUpdate = this.userService.updateUserPassword(newPassword, this.userService.getUser(userId));
}
}
map.put("isMatch", isMatch);
map.put("isUpdate", isUpdate);
map.put("messageUpdate", isUpdate?"更新成功":"更新失败");
map.put("messageMatch", isMatch?"密码正确":"密码不正确");
return map;
}