예제 #1
0
        public virtual async Task <IActionResult> OnPostAsync()
        {
            var user = await SignInManager.GetTwoFactorAuthenticationUserAsync();

            if (user == null)
            {
                Alerts.Warning("˫������֤ʧ��,�û�δ��¼!");
                return(Page());
            }

            if (SendCodeInput.SelectedProvider == "Authenticator")
            {
                var verifyAuthenticatorCodeInput = new VerifyAuthenticatorCodeInputModel
                {
                    ReturnUrl  = SendCodeInput.ReturnUrl,
                    RememberMe = SendCodeInput.RememberMe
                };
                return(RedirectToPage("VerifyAuthenticatorCode", verifyAuthenticatorCodeInput));
            }

            var code = await UserManager.GenerateTwoFactorTokenAsync(user, SendCodeInput.SelectedProvider);

            if (string.IsNullOrWhiteSpace(code))
            {
                Alerts.Warning("��֤������ʧ��,����ϵϵͳ����Ա!");
                return(Page());
            }

            var message = "Your security code is: " + code;

            if (SendCodeInput.SelectedProvider == "Email")
            {
                await EmailSender.SendAsync(await UserManager.GetEmailAsync(user), "Security Code", message);
            }
            else if (SendCodeInput.SelectedProvider == "Phone")
            {
                await SmsSender.SendAsync(await UserManager.GetPhoneNumberAsync(user), message);
            }

            var verifyCodeInput = new VerifyCodeInputModel
            {
                Provider   = SendCodeInput.SelectedProvider,
                ReturnUrl  = SendCodeInput.ReturnUrl,
                RememberMe = SendCodeInput.RememberMe
            };

            return(RedirectToPage("VerifyCode", verifyCodeInput));
        }
예제 #2
0
        public virtual IActionResult OnGet()
        {
            Input = new VerifyCodeInputModel();

            return(Page());
        }