Example #1
0
        public IActionResult VerifyCode(VerifyCodeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            // The following code protects for brute force attacks against the two factor codes.
            // If a user enters incorrect codes for a specified amount of time then the user account
            // will be locked out for a specified amount of time.
            Result result =  _loginService.TwoFactorSignInAsync(model.Provider, model.RecievedCode, model.Code, model.RememberMe, model.RememberBrowser);
            if (result.Succeeded)
            {
                return RedirectToLocal(model.ReturnUrl);
            }
            if (result.IsLockedOut)
            {
                _logger.LogWarning(7, "Ο χρήστης έχει απενεργοποιηθεί");
                return View("Lockout");
            }
            else
            {
                ModelState.AddModelError("", "Λάθος κωδικός.");
                return View(model);
            }
        }
Example #2
0
        public IActionResult VerifyCode(VerifyCodeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            
            Result result = _loginService.TwoFactorSignInAsync(model.Provider, model.RecievedCode, model.Code, model.RememberMe, model.RememberBrowser);
            if (result.Succeeded)
            {
                return new SignInResult(model.ReturnUrl);
                //return RedirectToLocal(model.ReturnUrl);
            }
            if (result.IsLockedOut)
            {
                _logger.LogWarning(7, "Ο χρήστης έχει απενεργοποιηθεί");
                return View("Lockout");
            }
            else
            {
                ModelState.AddModelError("", "Λάθος κωδικός.");
                return View(model);
            }
        }
Example #3
0
 public IActionResult VerifyCode(string recievedCode, string provider, bool rememberMe, string returnUrl = null)
 {
     // Require that the user has already logged in via username/password or external login
     //var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
     if (User == null)
     {
         return View("Error");
     }
     VerifyCodeViewModel vc = new VerifyCodeViewModel()
     {
         RecievedCode = recievedCode,
         Provider = provider,
         ReturnUrl = returnUrl,
         RememberMe = rememberMe
     };
     return View(vc);
 }