Пример #1
0
        public async Task<IActionResult> ExternalLoginCallback([FromQuery] string returnUrl, [FromQuery] string remoteError)
        {
            returnUrl = returnUrl ?? Url.Content("~/");

            Result<Microsoft.AspNetCore.Identity.SignInResult> proccessCallbackResult = await _externalLoginService.Callback(remoteError);
            if (proccessCallbackResult.Failure)
            {
                return RedirectToAction(nameof(Login), new { ReturnUrl = returnUrl });
            }

            if(proccessCallbackResult.Value.Succeeded)
            {
                return LocalRedirect(returnUrl);
            }
            if(proccessCallbackResult.Value.IsLockedOut)
            {
                return RedirectToAction(nameof(Lockout));
            }
            if(proccessCallbackResult.Value.RequiresTwoFactor)
            {
                return RedirectToAction(nameof(LoginWith2fa), new { ReturnUrl = returnUrl });
            }

            Result<ExternalLoginRegisterViewModel> getViewModelResult = await _accountDataService.GetExternalLoginViewModel(returnUrl);
            if(getViewModelResult.Failure)
            {
                LoginViewModel loginViewModel = await _accountDataService.GetLoginViewModel(returnUrl);
                return View(nameof(Login), loginViewModel);
            }

            return View("ExternalLoginRegister", getViewModelResult.Value);
        }