private bool IsNotAuthenticated()
        {
            CustomUserSession session = this.GetRequestSession();

            if (session == null)
            {
                return(false);
            }

            return(session.CurrentUserState == UserState.NotAuthenticated);
        }
Exemple #2
0
        public void SaveRequestSession<T>(T businessRequest, IHttpRequest httpRequest)
        {
            CustomUserSession userSession =
                GetRequestSession<T>(businessRequest, httpRequest);

            if (userSession != null)
            {
                RequestSessionFactory.Create<T>(httpRequest, businessRequest).
                    SaveRequestSession(userSession.TimeOut);
            }
        }
        protected CustomUserSession Build()
        {
            CustomUserSession session = this.GetRequestSession();

            if (this.sessionDto != null)
            {
                session.UserAuthId = this.sessionDto.LoginId;
                session.LoginId    = this.sessionDto.LoginId;
                session.RoleId     = this.sessionDto.RoleId;
                session.Roles      = this.sessionDto.Roles;
                session.TimeOut    = this.sessionDto.TimeOut;
            }

            session.IsAuthenticated  = true;
            session.CurrentUserState = UserState.Normal;

            return(session);
        }
        public virtual void CheckUserSession()
        {
            RequestSessionManager <T> rsMgr = RequestSessionFactory.Create <T>(httpRequest, this.businessRequest);

            if (rsMgr.GetCookies().Length == 0)
            {
                //throw new ArgumentException("请求没有携带Cookie值!");

                if (this.IsNormal())
                {
                    return;
                }
            }

            CustomUserSession session = this.GetRequestSession();

            if (session == null)
            {
                throw new Exception("CustomUserSession缓存实例NULL");
            }

            if (this.IsNotAuthenticated())
            {
                string loginId = string.Empty;
                if (this.sessionDto != null)
                {
                    loginId = this.sessionDto.LoginId;
                }

                throw new Exception(string.Format("没有登录或登录过期"));
            }

            if (this.IsNotAuthority())
            {
                throw new Exception("没有授权");
            }
        }