Search in sources :

Example 21 with SysUser

use of com.cdeledu.model.rbac.SysUser in project wechat by dllwh.

the class LoginFilter method isAccessAllowed.

/**
 * ----------------------------------------------------- Fields end
 */
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception {
    SysUser token = ShiroHelper.getPrincipal();
    if (token != null || isLoginRequest(request, response)) {
        return Boolean.TRUE;
    }
    if (FilterHelper.isAjax(request)) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        if (logger.isDebugEnabled()) {
            logger.debug("当前用户没有登录,并且是Ajax请求!");
        }
        HttpServletResponse httpresponse = (HttpServletResponse) response;
        httpresponse.setHeader("sessionstatus", "timeout");
        resultMap.put("success", false);
        resultMap.put("resultCode", 10001);
        resultMap.put("msg", "当前用户没有登录,需要重新登录");
        FilterHelper.out(response, resultMap);
        return Boolean.FALSE;
    }
    return Boolean.FALSE;
}
Also used : SysUser(com.cdeledu.model.rbac.SysUser) HashMap(java.util.HashMap) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

SysUser (com.cdeledu.model.rbac.SysUser)21 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 AjaxJson (com.cdeledu.common.base.AjaxJson)8 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 SystemLog (com.cdeledu.core.annotation.SystemLog)7 SysUserRole (com.cdeledu.model.rbac.SysUserRole)4 HttpSession (javax.servlet.http.HttpSession)3 AuthenticationException (org.apache.shiro.authc.AuthenticationException)2 DisabledAccountException (org.apache.shiro.authc.DisabledAccountException)2 ExcessiveAttemptsException (org.apache.shiro.authc.ExcessiveAttemptsException)2 LockedAccountException (org.apache.shiro.authc.LockedAccountException)2 UnknownAccountException (org.apache.shiro.authc.UnknownAccountException)2 Transactional (org.springframework.transaction.annotation.Transactional)2 OnlineUser (com.cdeledu.model.system.OnlineUser)1 HashMap (java.util.HashMap)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1 UsernamePasswordToken (org.apache.shiro.authc.UsernamePasswordToken)1 SimpleAuthorizationInfo (org.apache.shiro.authz.SimpleAuthorizationInfo)1 SimplePrincipalCollection (org.apache.shiro.subject.SimplePrincipalCollection)1