private string DoLogin(UserLogin userLogin, out UserToken userToken, out UserAccount userAccount)
        {
            string msg = "";

            userToken   = null;
            userAccount = null;

            DoValidateLogin(userLogin);
            if (msg.Length > 0)
            {
                Log.WriteErrorLog(msg); return(msg.ToMessageForUser());;
            }

            msg = UserAccount.Login(userLogin.UserName, out userAccount);
            if (msg.Length > 0)
            {
                return(msg);
            }
            if (userAccount == null)
            {
                return("Bạn nhập sai tên tài khoản hoặc mật khẩu".ToMessageForUser());
            }
            ;

            byte[] PasswordHash = Common.GetInputPasswordHash(userLogin.Password, userAccount.PasswordSalt);
            if (!userAccount.PasswordHash.SequenceEqual(PasswordHash))
            {
                return("Bạn nhập sai tên tài khoản hoặc mật khẩu".ToMessageForUser());
            }
            ;

            if (!userAccount.IsActive)
            {
                return(("Tài khoản của bạn đã bị khóa. Xin vui lòng liên hệ với CSKH").ToMessageForUser());
            }

            msg = CacheUserToken.CreateToken(userAccount, userLogin.IsRememberPassword, out userToken);
            if (msg.Length > 0)
            {
                return(msg);
            }

            return(msg);
        }
Esempio n. 2
0
 public Authentication()
 {
     ResultCheckToken = CacheUserToken.GetResultUserToken(out UserToken);
 }