From 1507b695c2a1f24dc388a6dc32b15f6e03c1bca1 Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 4 Dec 2025 21:15:20 +0800 Subject: [PATCH] chore: cleanup auth code Signed-off-by: Innei --- .../modules/platform/auth/auth.provider.ts | 53 +------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/be/apps/core/src/modules/platform/auth/auth.provider.ts b/be/apps/core/src/modules/platform/auth/auth.provider.ts index 3340abe3..931c154c 100644 --- a/be/apps/core/src/modules/platform/auth/auth.provider.ts +++ b/be/apps/core/src/modules/platform/auth/auth.provider.ts @@ -31,8 +31,6 @@ const logger = createLogger('Auth') @injectable() export class AuthProvider implements OnModuleInit { - private instances = new Map>() - constructor( private readonly config: AuthConfig, private readonly drizzleProvider: DrizzleProvider, @@ -66,21 +64,6 @@ export class AuthProvider implements OnModuleInit { } } - private buildCookiePrefix(tenantSlug: string | null): string { - if (!tenantSlug) { - return 'better-auth' - } - - const sanitizedSlug = tenantSlug - .trim() - .toLowerCase() - .replaceAll(/[^a-z0-9_-]/g, '-') - .replaceAll(/-+/g, '-') - .replaceAll(/^-|-$/g, '') - - return sanitizedSlug ? `better-auth-${sanitizedSlug}` : 'better-auth' - } - private async resolveTenantIdOrProvision(tenantSlug: string | null): Promise { const tenantIdFromContext = this.resolveTenantIdFromContext() if (tenantIdFromContext) { @@ -119,37 +102,7 @@ export class AuthProvider implements OnModuleInit { } } - private determineProtocol(host: string, provided: string | null): string { - if (provided && (provided === 'http' || provided === 'https')) { - return provided - } - if (host.includes('localhost') || host.startsWith('127.') || host.startsWith('0.0.0.0')) { - return 'http' - } - return 'https' - } - - private applyTenantSlugToHost(host: string, fallbackHost: string, tenantSlug: string | null): string { - if (!tenantSlug) { - return host - } - - const [hostName, hostPort] = host.split(':') as [string, string?] - if (hostName.startsWith(`${tenantSlug}.`)) { - return host - } - - const [fallbackName, fallbackPort] = fallbackHost.split(':') as [string, string?] - if (hostName !== fallbackName) { - return host - } - - const portSegment = hostPort ?? fallbackPort - return portSegment ? `${tenantSlug}.${fallbackName}:${portSegment}` : `${tenantSlug}.${fallbackName}` - } - private buildBetterAuthProvidersForHost( - tenantSlug: string | null, providers: SocialProvidersConfig, oauthGatewayUrl: string | null, ): Record { @@ -207,11 +160,7 @@ export class AuthProvider implements OnModuleInit { options: AuthModuleOptions, ): Promise { const db = this.drizzleProvider.getDb() - const socialProviders = this.buildBetterAuthProvidersForHost( - tenantSlug, - options.socialProviders, - options.oauthGatewayUrl, - ) + const socialProviders = this.buildBetterAuthProvidersForHost(options.socialProviders, options.oauthGatewayUrl) // Use tenant-aware adapter for multi-tenant user/account isolation // This ensures that user lookups (by email) and account lookups (by provider)