@At("/changePwd")
@GET
@Ok("beetl:user/change_pwd.html")
public Context changePwd(HttpSession session, @Param("p") String parameters) {
log.debugf("changePwd ---> " + new Date());
.....}
@At("/changePwd")
@POST
@Ok("redirect:/user/change_pwd?p=${parameters}")
@Fail("redirect:/user/login")
public String changePwd(@Param("p") String parameters, @Param("password") String password,
@Param("password2") String password2, HttpServletRequest request, HttpServletResponse response)
throws Exception {
ThreeDESUtil tools = new ThreeDESUtil();
log.info("parameters:" + parameters);
log.info("passwordA:" + password);
log.info("passwordB:" + password2);
Map<String, Object> map = tools.base64ToMap(parameters);
String uid = (String) map.get("uid");
String salt = (String) map.get("salt");
String email = (String) map.get("email");
String expire = (String) map.get("expire");
String warning_message = (String) map.get("warning_message");
log.info("uid:" + uid);
log.info("salt" + salt);
log.info("email" + email);
log.info("expire:" + expire);
log.info("warning_message:" + warning_message == null ? "null" : warning_message);
if (!Toolkit.checkPwd(password)) {
// 模板直接访问users
map.put("warning_message", "the password must be 8+ characters with at least 1 number!");
return tools.mapToBase64(map);
}
if (!password2.equals(password)) {
map.put("warning_message", "The tow password not same!");
return tools.mapToBase64(map);
}
int re = userService.updatePassword( map, Integer.valueOf(uid), salt, password);
if (re < 1) {
return tools.mapToBase64(map);
}
{
Exception e = new Exception("the password reset success."); // 创建异常对象
throw e; // 抛出异常
}
}