refactor: standardize the order of arguments
This commit is contained in:
parent
05166188be
commit
c4a4478b8c
@ -83,7 +83,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
|
|||||||
traceId,
|
traceId,
|
||||||
true), "text/html");
|
true), "text/html");
|
||||||
|
|
||||||
var result = await oAuthService.LoginOAuth(HttpContext, GetCookieParams(),
|
var result = await oAuthService.LoginOAuth(GetCookieParams(), HttpContext,
|
||||||
HttpContext.GetApiUrl(Url.Action("OAuth2")!), code, state);
|
HttpContext.GetApiUrl(Url.Action("OAuth2")!), code, state);
|
||||||
|
|
||||||
string? callbackUrl = null;
|
string? callbackUrl = null;
|
||||||
@ -136,7 +136,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
|
|||||||
if (!callback.IsAbsoluteUri)
|
if (!callback.IsAbsoluteUri)
|
||||||
throw new ControllerArgumentException("The callback URL must be absolute.");
|
throw new ControllerArgumentException("The callback URL must be absolute.");
|
||||||
|
|
||||||
return Redirect(oAuthService.GetProviderRedirect(HttpContext, GetCookieParams(),
|
return Redirect(oAuthService.GetProviderRedirect(GetCookieParams(), HttpContext,
|
||||||
HttpContext.GetApiUrl(Url.Action("OAuth2")!),
|
HttpContext.GetApiUrl(Url.Action("OAuth2")!),
|
||||||
(OAuthProvider)provider,
|
(OAuthProvider)provider,
|
||||||
callback).AbsoluteUri);
|
callback).AbsoluteUri);
|
||||||
|
@ -175,7 +175,7 @@ public class OAuthService(ILogger<OAuthService> logger, Dictionary<OAuthProvider
|
|||||||
cancellationToken: cancellation);
|
cancellationToken: cancellation);
|
||||||
|
|
||||||
|
|
||||||
public Uri GetProviderRedirect(HttpContext context, CookieOptions cookieOptions, string redirectUri,
|
public Uri GetProviderRedirect(CookieOptions cookieOptions, HttpContext context, string redirectUri,
|
||||||
OAuthProvider provider, Uri callback)
|
OAuthProvider provider, Uri callback)
|
||||||
{
|
{
|
||||||
var (clientId, _) = providers[provider];
|
var (clientId, _) = providers[provider];
|
||||||
@ -206,7 +206,7 @@ public class OAuthService(ILogger<OAuthService> logger, Dictionary<OAuthProvider
|
|||||||
public (OAuthProvider Provider, Uri Redirect)[] GetAvailableProviders(string redirectUri) =>
|
public (OAuthProvider Provider, Uri Redirect)[] GetAvailableProviders(string redirectUri) =>
|
||||||
[.. providers.Select(x => (x.Key, new Uri(redirectUri.TrimEnd('/') + "/?provider=" + (int)x.Key)))];
|
[.. providers.Select(x => (x.Key, new Uri(redirectUri.TrimEnd('/') + "/?provider=" + (int)x.Key)))];
|
||||||
|
|
||||||
public async Task<LoginOAuth> LoginOAuth(HttpContext context, CookieOptions cookieOptions,
|
public async Task<LoginOAuth> LoginOAuth(CookieOptions cookieOptions, HttpContext context,
|
||||||
string redirectUrl, string code, string state, CancellationToken cancellation = default)
|
string redirectUrl, string code, string state, CancellationToken cancellation = default)
|
||||||
{
|
{
|
||||||
var result = new LoginOAuth()
|
var result = new LoginOAuth()
|
||||||
@ -326,7 +326,8 @@ public class OAuthService(ILogger<OAuthService> logger, Dictionary<OAuthProvider
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(OAuthUser? User, string? Message, bool IsSuccess)> GetOAuthUser(HttpContext context, CookieOptions cookieOptions, string token, CancellationToken cancellation = default)
|
public async Task<(OAuthUser? User, string? Message, bool IsSuccess)>
|
||||||
|
GetOAuthUser(CookieOptions cookieOptions, HttpContext context, string token, CancellationToken cancellation = default)
|
||||||
{
|
{
|
||||||
var requestInfo = new RequestContextInfo(context, cookieOptions);
|
var requestInfo = new RequestContextInfo(context, cookieOptions);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user