Beispiel #1
0
        protected LoginInfo SignIn(MafUser user, string psw, bool isRememberMe, List <string> errList)
        {
            LoginInfo info;

            try
            {
                // 建立登录信息
                info = new LoginInfo(user, psw, isRememberMe);
                CollectClientInfo(info);
            }
            catch (Exception ex)
            {
                if (errList != null)
                {
                    errList.Add(ex.Message);
                }
                return(null);
            }

            // 记录在服务端
            SignInServer(info);

            // 记录在客户端
            SignInClient(info);

            return(info);
        }
Beispiel #2
0
        internal MafIdentity(MafUser user)
            : this()
        {
            IsAuthenticated = user.GetType() != typeof(MafAnonymousUser);

            Name = user.Name;
            User = user;
        }
Beispiel #3
0
        public LoginInfo(MafUser user, string psw, bool isRememberMe)
            : this()
        {
            if (user == null)
            {
                throw new SecurityException("用户名不存在");
            }

            if (user.Password != psw)
            {
                throw new SecurityException("密码错误");
            }

            UserName    = user.Name;
            IsAnonymous = typeof(MafAnonymousUser) == user.GetType();
            ExpireTime  = isRememberMe ? ExpireTime.AddYears(100) : ExpireTime.AddDays(1);
        }
Beispiel #4
0
 public MafPrincipal(Guid token, MafUser user)
 {
     Token    = token;
     Identity = new MafIdentity(user);
 }