Пример #1
0
        public async Task <IActionResult> ExternalLoginCallBack(string returnTo = null, string remoteError = null)
        {
            if (!string.IsNullOrEmpty(remoteError) || !string.IsNullOrWhiteSpace(remoteError))
            {
                return(View("Error"));
            }

            var info = await _signInManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                return(View("Error"));
            }

            var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, false);

            if (result.Succeeded)
            {
                await _signInManager.UpdateExternalAuthenticationTokensAsync(info);

                return(RedirectToLocal(returnTo));
            }

            if (result.IsLockedOut)
            {
                return(View("LockOut"));
            }

            if (result.RequiresTwoFactor)
            {
                return(RedirectToRoute("GetSendCode", new { returnTo }));
            }
            else
            {
                ViewData["returnTo"] = returnTo;


                var email = info.Principal.FindFirstValue(ClaimTypes.Email);

                var model = new ExternalLoginConfirm
                {
                    Email = email
                };

                return(View("ExternalLoginConfirm", model));
            }
        }