Esempio n. 1
0
 /**
  * 客户端包含
  *
  * @param request
  * @param model
  * @return
  */
 @RequestMapping(value = "/login_csi.jspx")
 public String csi(HttpServletRequest request, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   // 将request中所有参数
   model.putAll(RequestUtils.getQueryParams(request));
   FrontUtils.frontData(request, model, site);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_CSI, LOGIN_CSI);
 }
Esempio n. 2
0
 @RequestMapping(value = "/public_bind_username.jspx")
 public String bind_username_post(
     String username, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
   CmsSite site = CmsUtils.getSite(request);
   WebErrors errors = WebErrors.create(request);
   String source = "";
   if (StringUtils.isBlank(username)) {
     // 用户名为空
     errors.addErrorCode("error.usernameRequired");
   } else {
     boolean usernameExist = unifiedUserMng.usernameExist(username);
     if (usernameExist) {
       // 用户名存在
       errors.addErrorCode("error.usernameExist");
     } else {
       // 获取用户来源
       String openId = (String) session.getAttribute(request, CmsThirdAccount.QQ_KEY);
       String uid = (String) session.getAttribute(request, CmsThirdAccount.SINA_KEY);
       String weboOpenId = (String) session.getAttribute(request, CmsThirdAccount.QQ_WEBO_KEY);
       // (获取到登录授权key后可以注册用户)
       if (StringUtils.isNotBlank(openId)
           || StringUtils.isNotBlank(uid)
           || StringUtils.isNotBlank(weboOpenId)) {
         // 初始设置密码同用户名
         cmsUserMng.registerMember(
             username,
             null,
             username,
             RequestUtils.getIpAddr(request),
             null,
             null,
             false,
             new CmsUserExt(),
             null);
       }
       if (StringUtils.isNotBlank(openId)) {
         source = CmsThirdAccount.QQ_PLAT;
       } else if (StringUtils.isNotBlank(uid)) {
         source = CmsThirdAccount.SINA_PLAT;
       } else if (StringUtils.isNotBlank(weboOpenId)) {
         source = CmsThirdAccount.QQ_WEBO_PLAT;
       }
       // 提交登录并绑定账号
       loginByUsername(username, request, response, model);
     }
   }
   if (errors.hasErrors()) {
     errors.toModel(model);
     model.addAttribute("success", false);
   } else {
     model.addAttribute("success", true);
   }
   model.addAttribute("source", source);
   FrontUtils.frontData(request, model, site);
   return FrontUtils.getTplPath(request, site.getSolutionPath(), TPLDIR_MEMBER, TPL_BIND);
 }