示例#1
0
        public virtual ActionResult Login(SignIdModel user)
        {
            if (!ModelState.IsValid)
            {
                return(View(user));
            }

            if (!_authentication.Authenticate(user))
            {
                ModelState.AddModelError("Login", Validation.WrongLoginOrPassword);
                return(View(user));
            }

            return(RedirectToAction(MVC.Home.Index()));
        }
示例#2
0
        public bool Authenticate(SignIdModel user)
        {
            var data = _users.GetPasswordData(user.Login);

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

            var hash = _passwordConverter.GetPasswordHash(user.Password, data.PasswordSalt.ToArray());

            if (!hash.SequenceEqual(data.PasswordHash))
            {
                return(false);
            }

            AuthenticateForce(data.UserId, user.RememberMe);

            return(true);
        }