Exemple #1
0
  /** 管理登录 */
  @RequestMapping(value = "${adminPath}/login", method = RequestMethod.GET)
  public String login(HttpServletRequest request, HttpServletResponse response, Model model) {
    ShiroDbRealm.Principal principal = UserUtils.getPrincipal();

    //		// 默认页签模式
    //		String tabmode = CookieUtils.getCookie(request, "tabmode");
    //		if (tabmode == null){
    //			CookieUtils.setCookie(response, "tabmode", "1");
    //		}

    if (logger.isDebugEnabled()) {
      logger.debug("login, active session size: {}", sessionDAO.getActiveSessions(false).size());
    }

    // 如果已登录,再次访问主页,则退出原账号。
    if (Global.TRUE.equals(Global.getConfig("notAllowRefreshIndex"))) {
      CookieUtils.setCookie(response, "LOGINED", "false");
    }

    // 如果已经登录,则跳转到管理首页
    //		if(principal != null){
    //			return "redirect:" + adminPath;
    //		}
    //		String view;
    //		view = "/WEB-INF/views/modules/sys/sysLogin.jsp";
    //		view = "classpath:";
    //		view += "jar:file:/D:/GitHub/jeesite/src/main/webapp/WEB-INF/lib/jeesite.jar!";
    //		view += "/"+getClass().getName().replaceAll("\\.", "/").replace(getClass().getSimpleName(),
    // "")+"view/sysLogin";
    //		view += ".jsp";
    return "login";
  }
Exemple #2
0
  /** 登录成功,进入管理首页 */
  @RequiresRoles("user")
  @RequestMapping(value = "${adminPath}")
  public String index(HttpServletRequest request, HttpServletResponse response) {
    ShiroDbRealm.Principal principal = UserUtils.getPrincipal();

    // 登录成功后,验证码计算器清零
    isValidateCodeLogin(principal.loginName, false, true);

    if (logger.isDebugEnabled()) {
      logger.debug(
          "show index, active session size: {}", sessionDAO.getActiveSessions(false).size());
    }

    // 如果已登录,再次访问主页,则退出原账号。
    if (Global.TRUE.equals(Global.getConfig("notAllowRefreshIndex"))) {
      String logined = CookieUtils.getCookie(request, "LOGINED");
      if (StringUtils.isBlank(logined) || "false".equals(logined)) {
        CookieUtils.setCookie(response, "LOGINED", "true");
      } else if (StringUtils.equals(logined, "true")) {
        UserUtils.getSubject().logout();
        response.setStatus(401);
        return renderString(response, "");
      }
    }

    // 如果是手机登录,则返回JSON字符串
    //		if (principal.isMobileLogin()){
    //			if (request.getParameter("login") != null){
    //				return renderString(response, principal);
    //			}
    //			if (request.getParameter("index") != null){
    //				return "modules/sys/sysIndex";
    //			}
    //			return "redirect:" + adminPath + "/login";
    //		}

    //		// 登录成功后,获取上次登录的当前站点ID
    //		UserUtils.putCache("siteId", StringUtils.toLong(CookieUtils.getCookie(request, "siteId")));

    //		System.out.println("==========================a");
    //		try {
    //			byte[] bytes = com.thinkgem.jeesite.common.utils.FileUtils.readFileToByteArray(
    //					com.thinkgem.jeesite.common.utils.FileUtils.getFile("c:\\sxt.dmp"));
    //			UserUtils.getSession().setAttribute("kkk", bytes);
    //			UserUtils.getSession().setAttribute("kkk2", bytes);
    //		} catch (Exception e) {
    //			e.printStackTrace();
    //		}
    ////		for (int i=0; i<1000000; i++){
    ////			//UserUtils.getSession().setAttribute("a", "a");
    ////			request.getSession().setAttribute("aaa", "aa");
    ////		}
    //		System.out.println("==========================b");
    return renderString(response, principal);
  }