refactor: standardize the order of arguments

This commit is contained in:
nikita 2024-12-26 15:46:30 +03:00
parent 05166188be
commit c4a4478b8c
2 changed files with 6 additions and 5 deletions

View File

@ -83,7 +83,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
traceId,
true), "text/html");
var result = await oAuthService.LoginOAuth(HttpContext, GetCookieParams(),
var result = await oAuthService.LoginOAuth(GetCookieParams(), HttpContext,
HttpContext.GetApiUrl(Url.Action("OAuth2")!), code, state);
string? callbackUrl = null;
@ -136,7 +136,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
if (!callback.IsAbsoluteUri)
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")!),
(OAuthProvider)provider,
callback).AbsoluteUri);

View File

@ -175,7 +175,7 @@ public class OAuthService(ILogger<OAuthService> logger, Dictionary<OAuthProvider
cancellationToken: cancellation);
public Uri GetProviderRedirect(HttpContext context, CookieOptions cookieOptions, string redirectUri,
public Uri GetProviderRedirect(CookieOptions cookieOptions, HttpContext context, string redirectUri,
OAuthProvider provider, Uri callback)
{
var (clientId, _) = providers[provider];
@ -206,7 +206,7 @@ public class OAuthService(ILogger<OAuthService> logger, Dictionary<OAuthProvider
public (OAuthProvider Provider, Uri Redirect)[] GetAvailableProviders(string redirectUri) =>
[.. 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)
{
var result = new LoginOAuth()
@ -326,7 +326,8 @@ public class OAuthService(ILogger<OAuthService> logger, Dictionary<OAuthProvider
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);