Exemplo n.º 1
0
        public async Task <ActionResult> VerifyCode(string provider, string returnUrl)
        {
            if (!await SignInHelper.HasBeenVerified())
            {
                return(View("Error"));
            }
            var user = await UserManager.FindByIdAsync(await SignInHelper.GetVerifiedUserIdAsync());

            if (user != null)
            {
            }
            return(View(new VerifyCodeViewModel {
                Provider = provider, ReturnUrl = returnUrl
            }));
        }
Exemplo n.º 2
0
 public async Task<ActionResult> VerifyCode(string provider, string returnUrl)
 {
     // Require that the user has already logged in via username/password or external login
     if (!await SignInHelper.HasBeenVerified())
     {
         return View("Error");
     }
     var user = await UserManager.FindByIdAsync(await SignInHelper.GetVerifiedUserIdAsync());
     if (user != null)
     {
         // To exercise the flow without actually sending codes, uncomment the following line
         ViewBag.Status = "For DEMO purposes the current " + provider + " code is: " + await UserManager.GenerateTwoFactorTokenAsync(user.Id, provider);
     }
     return View(new VerifyCodeViewModel { Provider = provider, ReturnUrl = returnUrl });
 }
        public async Task <ActionResult> SendCode(string returnUrl)
        {
            var userId = await SignInHelper.GetVerifiedUserIdAsync();

            if (userId == null)
            {
                return(View("Error"));
            }
            var userFactors = await UserManager.GetValidTwoFactorProvidersAsync(userId);

            var factorOptions = userFactors.Select(purpose => new SelectListItem {
                Text = purpose, Value = purpose
            }).ToList();

            return(View(new SendCodeViewModel {
                Providers = factorOptions, ReturnUrl = returnUrl
            }));
        }
        public async Task <ActionResult> VerifyCode(string provider, string returnUrl, bool rememberMe)
        {
            // 要求用户已通过使用用户名/密码或外部登录名登录
            if (!await SignInManager.HasBeenVerifiedAsync())
            {
                return(View("Error"));
            }
            var user = await UserManager.FindByIdAsync(await SignInHelper.GetVerifiedUserIdAsync());

            if (user != null)
            {
                // To exercise the flow without actually sending codes, uncomment the following line
                ViewBag.Status = "For DEMO purposes the current " + provider + " code is: " + await UserManager.GenerateTwoFactorTokenAsync(user.Id, provider);
            }
            return(View(new VerifyCodeViewModel {
                Provider = provider, ReturnUrl = returnUrl, RememberMe = rememberMe
            }));
        }