Пример #1
0
        public async Task<IActionResult> ExternalLogin(ExternalLoginRequest externalLoginRequest, string returnUrl)
        {
            returnUrl = returnUrl ?? Url.Content("~/");

            if (!ModelState.IsValid)
            {
                LoginViewModel loginViewModel = await _accountDataService.GetLoginViewModel(returnUrl);
                return View(nameof(Login), loginViewModel);
            }

            Result<AuthenticationProperties> result = await _externalLoginService.ExternalLogin(externalLoginRequest, returnUrl);
            if(result.Failure)
            {
                LoginViewModel loginViewModel = await _accountDataService.GetLoginViewModel(returnUrl);
                return View(nameof(Login), loginViewModel);
            }

            return Challenge(result.Value, externalLoginRequest.Provider);
        }