// 激活账号 @RequestMapping(value = "/active.jspx", method = RequestMethod.GET) public String active( String username, String key, HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException { CmsSite site = CmsUtils.getSite(request); WebErrors errors = validateActive(username, key, request, response); if (errors.hasErrors()) { return FrontUtils.showError(request, response, model, errors); } UnifiedUser user = unifiedUserMng.active(username, key); BbsUser bbsUser = bbsUserMng.findById(user.getId()); String ip = RequestUtils.getIpAddr(request); authMng.activeLogin(user, ip, request, response, session); // 登录记录 BbsLoginLog loginLog = new BbsLoginLog(); loginLog.setIp(RequestUtils.getIpAddr(request)); Calendar calendar = Calendar.getInstance(); loginLog.setLoginTime(calendar.getTime()); loginLog.setUser(bbsUser); bbsLoginMng.save(loginLog); // 在线时长统计 BbsUserOnline online = bbsUser.getUserOnline(); // 首次登陆 online = new BbsUserOnline(); online.setUser(bbsUser); online.initial(); userOnlineMng.save(online); FrontUtils.frontData(request, model, site); return FrontUtils.getTplPath( request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_ACTIVE_SUCCESS); }
@RequestMapping(value = "/topic/search*.jhtml") public String searchSubmit(Integer pageNo, HttpServletRequest request, ModelMap model) { CmsSite site = CmsUtils.getSite(request); FrontUtils.frontData(request, model, site); String keywords = RequestUtils.getQueryParam(request, "keywords"); String forumIdStr = RequestUtils.getQueryParam(request, "forumId"); Integer forumId = 0; if (forumIdStr != null && StringUtils.isNotBlank(forumIdStr)) { forumId = Integer.parseInt(forumIdStr); } model.put("keywords", keywords); model.put("forumId", forumId); FrontUtils.frontPageData(request, model); return FrontUtils.getTplPath(request, site, TPLDIR_SPECIAL, SEARCH_RESULT); }
@RequestMapping(value = "/register.jspx", method = RequestMethod.POST) public String submit( String username, String email, String password, BbsUserExt userExt, String captcha, String nextUrl, HttpServletRequest request, HttpServletResponse response, ModelMap model) throws IOException { CmsSite site = CmsUtils.getSite(request); BbsConfig config = bbsConfigMng.findById(site.getId()); 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); Integer groupId = null; BbsUserGroup group = bbsConfigMng.findById(site.getId()).getRegisterGroup(); if (group != null) { groupId = group.getId(); } BbsUser user = null; if (config.getEmailValidate()) { EmailSender sender = configMng.getEmailSender(); MessageTemplate msgTpl = configMng.getRegisterMessageTemplate(); if (sender == null) { // 邮件服务器没有设置好 model.addAttribute("status", 4); } else if (msgTpl == null) { // 邮件模板没有设置好 model.addAttribute("status", 5); } else { try { user = bbsUserMng.registerMember( username, email, password, ip, groupId, userExt, false, sender, msgTpl); bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId()); model.addAttribute("status", 0); } catch (Exception e) { // 发送邮件异常 model.addAttribute("status", 100); model.addAttribute("message", e.getMessage()); log.error("send email exception.", e); } } log.info("member register success. username={}", username); if (!StringUtils.isBlank(nextUrl)) { response.sendRedirect(nextUrl); return null; } else { FrontUtils.frontData(request, model, site); FrontUtils.frontPageData(request, model); return FrontUtils.getTplPath( request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER_RESULT); } } else { user = bbsUserMng.registerMember(username, email, password, ip, groupId, userExt); bbsConfigEhCache.setBbsConfigCache(0, 0, 0, 1, user, site.getId()); log.info("member register success. username={}", username); FrontUtils.frontData(request, model, site); FrontUtils.frontPageData(request, model); model.addAttribute("success", true); return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, LOGIN_INPUT); } /* * BbsUser user = bbsUserMng.registerMember(username, email, password, * ip, groupId, userExt); */ }
@RequestMapping(value = "/register.jspx", method = RequestMethod.GET) public String input(HttpServletRequest request, HttpServletResponse response, ModelMap model) { CmsSite site = CmsUtils.getSite(request); FrontUtils.frontData(request, model, site); return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, REGISTER); }