/** * 密码修改提交页 * * @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); }
/** * 会员中心页 * * <p>如果没有登录则跳转到登陆页 * * @param request * @param response * @param model * @return */ @RequestMapping(value = "/member/index.jspx", method = RequestMethod.GET) public String index(HttpServletRequest request, HttpServletResponse response, ModelMap model) { 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); } return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, MEMBER_CENTER); }
@RequestMapping(value = "/register.jspx", method = RequestMethod.POST) public String submit( String username, String email, String password, CmsUserExt userExt, String captcha, String nextUrl, HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException { CmsSite site = CmsUtils.getSite(request); WebErrors errors = validateSubmit(username, email, password, captcha, site, request, response); if (errors.hasErrors()) { return FrontUtils.showError(request, response, model, errors); } String ip = RequestUtils.getIpAddr(request); cmsUserMng.registerMember(username, email, password, ip, null, userExt); log.info("member register success. username={}", username); if (!StringUtils.isBlank(nextUrl)) { response.sendRedirect(nextUrl); return null; } else { return FrontUtils.showMessage(request, model, "global.success"); } }
private WebErrors validateUpdate(Integer id, HttpServletRequest request) { WebErrors errors = WebErrors.create(request); CmsSite site = CmsUtils.getSite(request); if (vldExist(id, site.getId(), errors)) { return errors; } return errors; }
@RequestMapping("/vote_topic/v_list.do") public String list(Integer pageNo, HttpServletRequest request, ModelMap model) { CmsSite site = CmsUtils.getSite(request); Pagination pagination = manager.getPage(site.getId(), cpn(pageNo), CookieUtils.getPageSize(request)); model.addAttribute("pagination", pagination); model.addAttribute("pageNo", pagination.getPageNo()); return "vote_topic/list"; }
private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) { WebErrors errors = WebErrors.create(request); CmsSite site = CmsUtils.getSite(request); if (errors.ifEmpty(ids, "ids")) { return errors; } for (Integer id : ids) { vldExist(id, site.getId(), errors); } return errors; }
/** * 个人资料提交页 * * @param request * @param response * @param model * @return * @throws IOException */ @RequestMapping(value = "/member/profile.jspx", method = RequestMethod.POST) public String profileSubmit( CmsUserExt ext, 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); } ext.setId(user.getId()); cmsUserExtMng.update(ext, user); log.info("update CmsUserExt success. id={}", user.getId()); return FrontUtils.showSuccess(request, model, nextUrl); }
@RequestMapping(value = "/register.jspx", method = RequestMethod.GET) public String input(HttpServletRequest request, HttpServletResponse response, ModelMap model) { CmsSite site = CmsUtils.getSite(request); MemberConfig mcfg = site.getConfig().getMemberConfig(); // 没有开启会员功能 if (!mcfg.isMemberOn()) { return FrontUtils.showMessage(request, model, "member.memberClose"); } // 没有开启会员注册 if (!mcfg.isRegisterOn()) { return FrontUtils.showMessage(request, model, "member.registerClose"); } FrontUtils.frontData(request, model, site); model.addAttribute("mcfg", mcfg); return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER); }
@RequestMapping(value = "/username_unique.jspx") public void usernameUnique(HttpServletRequest request, HttpServletResponse response) { String username = RequestUtils.getQueryParam(request, "username"); // 用户名为空,返回false。 if (StringUtils.isBlank(username)) { ResponseUtils.renderJson(response, "false"); return; } CmsSite site = CmsUtils.getSite(request); CmsConfig config = site.getConfig(); // 保留字检查不通过,返回false。 if (!config.getMemberConfig().checkUsernameReserved(username)) { ResponseUtils.renderJson(response, "false"); return; } // 用户名存在,返回false。 if (unifiedUserMng.usernameExist(username)) { ResponseUtils.renderJson(response, "false"); return; } ResponseUtils.renderJson(response, "true"); }
private WebErrors validateSave(CmsVoteTopic bean, HttpServletRequest request) { WebErrors errors = WebErrors.create(request); CmsSite site = CmsUtils.getSite(request); bean.setSite(site); return errors; }
/** * 验证密码是否正确 * * @param origPwd 原密码 * @param request * @param response */ @RequestMapping("/member/checkPwd.jspx") public void checkPwd(String origPwd, HttpServletRequest request, HttpServletResponse response) { CmsUser user = CmsUtils.getUser(request); boolean pass = cmsUserMng.isPasswordValid(user.getId(), origPwd); ResponseUtils.renderJson(response, pass ? "true" : "false"); }