예제 #1
0
 /**
  * 密码修改提交页
  *
  * @param origPwd 原始密码
  * @param newPwd 新密码
  * @param email 邮箱
  * @param nextUrl 下一个页面地址
  * @param request
  * @param response
  * @param model
  * @return
  * @throws IOException
  */
 @RequestMapping(value = "/member/pwd.jspx", method = RequestMethod.POST)
 public String passwordSubmit(
     String origPwd,
     String newPwd,
     String email,
     String nextUrl,
     HttpServletRequest request,
     HttpServletResponse response,
     ModelMap model)
     throws IOException {
   CmsSite site = CmsUtils.getSite(request);
   CmsUser user = CmsUtils.getUser(request);
   FrontUtils.frontData(request, model, site);
   MemberConfig mcfg = site.getConfig().getMemberConfig();
   // 没有开启会员功能
   if (!mcfg.isMemberOn()) {
     return FrontUtils.showMessage(request, model, "member.memberClose");
   }
   if (user == null) {
     return FrontUtils.showLogin(request, model, site);
   }
   WebErrors errors = validatePasswordSubmit(user.getId(), origPwd, newPwd, email, request);
   if (errors.hasErrors()) {
     return FrontUtils.showError(request, response, model, errors);
   }
   cmsUserMng.updatePwdEmail(user.getId(), newPwd, email);
   return FrontUtils.showSuccess(request, model, nextUrl);
 }
예제 #2
0
 private WebErrors validatePasswordSubmit(
     Integer id, String origPwd, String newPwd, String email, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (errors.ifBlank(origPwd, "origPwd", 100)) {
     return errors;
   }
   if (errors.ifMaxLength(newPwd, "newPwd", 100)) {
     return errors;
   }
   if (errors.ifNotEmail(email, "email", 100)) {
     return errors;
   }
   if (!cmsUserMng.isPasswordValid(id, origPwd)) {
     errors.addErrorCode("member.origPwdInvalid");
     return errors;
   }
   return errors;
 }