Exemplo n.º 1
0
        private bool IsNotAuthenticated()
        {
            CustomUserSession session = this.GetRequestSession();

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

            return(session.CurrentUserState == UserState.NotAuthenticated);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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("没有授权");
            }
        }