Пример #1
0
        public User CheckLogin(string username, string password)
        {
            User user = _repositoryUser.Find(u =>
                                             u.Username == username && u.Status.Equals(UserStatus.Active));

            if (user != null)
            {
                if (password.Equals(_hashingData.DecryptString(user.Password, AppSettingConstant.PasswordHash)))
                {
                    return(user);
                }
            }

            return(null);
        }
Пример #2
0
        public User CheckLogin(string username, string password, string role)
        {
            User user = _repositoryUser.Find(u =>
                                             u.Username == username & u.Status.ToLower() != Status.Deleted.ToLower() & u.Role.ToLower() == role.ToLower());

            if (user != null)
            {
                if (password.Equals(_hashingData.DecryptString(user.Password, AppSettingConstant.PasswordHash)))
                {
                    return(user);
                }
            }

            return(null);
        }
Пример #3
0
        // GET: Admin/Login
        public ActionResult Index()
        {
            HashingData hashing = new HashingData();
            var         key     = TempData["key"] as string;

            if (key != null)
            {
                try
                {
                    var decodeKey = hashing.DecryptString(hashing.Decode(key), AppSettingConstant.PasswordHash);
                    var when      = DateTime.Parse(decodeKey);
                    if (when > DateTime.UtcNow.AddHours(-24))
                    {
                        return(View());
                    }
                }
                catch (Exception e)
                {
                }
            }

            return(Redirect("/error-404"));
        }