Esempio n. 1
0
        public IActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var user = AccountManager.ValidateAsync(model, HttpContext, db);

                if (user?.Result != null)
                {
                    AccountManager.Authenticate(user.Result, HttpContext);

                    if (user.Result.Role.RoleName == "user")
                    {
                        var hash = TwoFactorAuth.GetTwoFactorHash();
                        if (TwoFactorAuth.HashIsRigth(hash))
                        {
                            return(RedirectToAction("Office", "PersonalOffice"));
                        }
                    }
                }
                ModelState.AddModelError("", "Некорректные логин и(или) пароль");
            }
            return(View(model));
        }