From cd03c7487a2550ab21b4c5388070f75ab55cb15b Mon Sep 17 00:00:00 2001 From: DarioGii Date: Thu, 23 Oct 2025 11:58:35 +0100 Subject: [PATCH] cleaning up --- .../src/main/resources/settings.yml.template | 2 +- frontend/src/auth/UseSession.tsx | 2 +- frontend/src/auth/springAuthClient.ts | 32 +++---------------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/app/core/src/main/resources/settings.yml.template b/app/core/src/main/resources/settings.yml.template index 28f7471d8..ebd0cbfc2 100644 --- a/app/core/src/main/resources/settings.yml.template +++ b/app/core/src/main/resources/settings.yml.template @@ -20,7 +20,7 @@ security: username: '' # initial username for the first login password: '' # initial password for the first login oauth2: - enabled: true # set to 'true' to enable login (Note: enableLogin must also be 'true' for this to work) + enabled: false # set to 'true' to enable login (Note: enableLogin must also be 'true' for this to work) client: keycloak: issuer: '' # URL of the Keycloak realm's OpenID Connect Discovery endpoint diff --git a/frontend/src/auth/UseSession.tsx b/frontend/src/auth/UseSession.tsx index a0aa9d4cf..7728627f1 100644 --- a/frontend/src/auth/UseSession.tsx +++ b/frontend/src/auth/UseSession.tsx @@ -28,7 +28,7 @@ const AuthContext = createContext({ * Auth Provider Component * * Manages authentication state and provides it to the entire app. - * Replaces Supabase's AuthProvider with Spring Security + JWT integration. + * Integrates with Spring Security + JWT backend. */ export function AuthProvider({ children }: { children: ReactNode }) { const [session, setSession] = useState(null); diff --git a/frontend/src/auth/springAuthClient.ts b/frontend/src/auth/springAuthClient.ts index e5091ba4d..806e4a334 100644 --- a/frontend/src/auth/springAuthClient.ts +++ b/frontend/src/auth/springAuthClient.ts @@ -1,16 +1,13 @@ /** - * Spring Auth Client - Replaces Supabase client + * Spring Auth Client * - * This client provides the same API surface as Supabase for authentication, - * but integrates with the Spring Security + JWT backend instead. - * - * Main differences from Supabase: + * This client integrates with the Spring Security + JWT backend. * - Uses localStorage for JWT storage (sent via Authorization header) * - JWT validation handled server-side * - No email confirmation flow (auto-confirmed on registration) */ -// Types matching Supabase structure for compatibility +// Auth types export interface User { id: string; email: string; @@ -47,10 +44,6 @@ export type AuthChangeEvent = type AuthChangeCallback = (event: AuthChangeEvent, session: Session | null) => void; -/** - * Spring Auth Client - Replaces Supabase client - * Maintains same API surface as Supabase for easy migration - */ class SpringAuthClient { private listeners: AuthChangeCallback[] = []; private sessionCheckInterval: NodeJS.Timeout | null = null; @@ -338,7 +331,7 @@ class SpringAuthClient { } /** - * Listen to auth state changes (mimics Supabase onAuthStateChange) + * Listen to auth state changes */ onAuthStateChange(callback: AuthChangeCallback): { data: { subscription: { unsubscribe: () => void } } } { this.listeners.push(callback); @@ -401,23 +394,8 @@ class SpringAuthClient { } } -// Export singleton instance (mimics Supabase pattern) export const springAuth = new SpringAuthClient(); -// Export helper functions (matching Supabase exports) - -/** - * Anonymous sign-in - * Note: Not implemented yet - returns error - */ -export const signInAnonymously = async () => { - // For now, return error - implement anonymous auth if needed - return { - data: { user: null, session: null }, - error: { message: 'Anonymous authentication not implemented' }, - }; -}; - /** * Get current user */ @@ -464,4 +442,4 @@ export const createAnonymousSession = (): Session => { }; // Export auth client as default for convenience -export default springAuth; \ No newline at end of file +export default springAuth;