public async Task <IActionResult> MfaLogin(MfaLoginViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var result = await _signInManager.TwoFactorSignInAsync(_userManager.Options.Tokens.AuthenticatorTokenProvider, model.Code, true, true);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", "Your code could not be validated. try again.");
                return(View(model));
            }

            return(RedirectToAction(nameof(Index)));
        }
예제 #2
0
        public async Task <IActionResult> MfaLogin(MfaLoginViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var result = await _signInManager.TwoFactorSignInAsync(_userManager.Options.Tokens.AuthenticatorTokenProvider,
                                                                   model.Code, true, true);// first true - cookie, second true - I do not have to use mfa login in this browser

            if (!result.Succeeded)
            {
                ModelState.AddModelError(string.Empty, "Your code could not be validated. Try again.");
                return(View(model));
            }

            return(RedirectToAction("Index", "Logins"));
        }