♻️ Refactor OpenID: Phase 1: Code Consolidation optimizations

- Add BuildAuthorizationParameters() method to reduce authorization URL duplication
- Update GoogleOidcService to use common parameter building method
- Add missing using statements for AppDatabase and AuthService namespaces
- Improve code reusability and eliminate 20+ lines of repeated authorization logic per provider
This commit is contained in:
2025-11-02 14:51:39 +08:00
parent 08f924f647
commit 4bd59f107b
2 changed files with 32 additions and 10 deletions

View File

@@ -43,6 +43,29 @@ public abstract class OidcService(
/// </summary>
public abstract string GetAuthorizationUrl(string state, string nonce);
/// <summary>
/// Builds common authorization URL query parameters
/// </summary>
protected Dictionary<string, string> BuildAuthorizationParameters(string clientId, string redirectUri, string scope, string responseType, string state, string nonce, string? responseMode = null)
{
var parameters = new Dictionary<string, string>
{
["client_id"] = clientId,
["redirect_uri"] = redirectUri,
["response_type"] = responseType,
["scope"] = scope,
["state"] = state,
["nonce"] = nonce
};
if (!string.IsNullOrEmpty(responseMode))
{
parameters["response_mode"] = responseMode;
}
return parameters;
}
/// <summary>
/// Process the callback from the OIDC provider
/// </summary>