示例#1
0
        public async Task <Result <AuthenticationProperties> > ExternalLogin(ExternalLoginRequest externalLoginRequest, string returnUrl)
        {
            ValidationResult validationResult = _externalLoginRequestValidator.Validate(externalLoginRequest);

            if (!validationResult.IsValid)
            {
                _logger.LogWarning($"Invalid {nameof(ExternalLoginRequest)} model");
                return(Result.Fail <AuthenticationProperties>(validationResult.Errors));
            }

            await _signInManager.SignOutAsync();

            string redirectUrl = _urlGenerator.GenerateActionUrl("ExternalLoginCallback", "Account", new { returnUrl });

            AuthenticationProperties properties = _signInManager.ConfigureExternalAuthenticationProperties(externalLoginRequest.Provider, redirectUrl);

            return(Result.Ok(properties));
        }