- Added Firebase as a dependency for authentication. - Created AuthProvider to manage authentication state and user sessions. - Implemented AuthStatus component to display authentication status in the UI. - Added verifyFirebaseIdToken function to validate Firebase ID tokens against the backend. - Updated API endpoints to include Firebase OAuth verification. - Enhanced ShowsPage to allow authenticated users to delete shows. - Updated configuration to include Firebase settings and authentication enablement. - Styled authentication components and added necessary CSS for better UI.
18 lines
497 B
TypeScript
18 lines
497 B
TypeScript
import { getApp, getApps, initializeApp, type FirebaseApp } from "firebase/app";
|
|
import { config } from "../config";
|
|
|
|
let cachedApp: FirebaseApp | null = null;
|
|
|
|
export function getFirebaseApp(): FirebaseApp {
|
|
if (cachedApp) return cachedApp;
|
|
if (!config.auth.enabled) {
|
|
throw new Error("Firebase auth not enabled");
|
|
}
|
|
if (!getApps().length) {
|
|
cachedApp = initializeApp(config.auth.firebase);
|
|
} else {
|
|
cachedApp = getApp();
|
|
}
|
|
return cachedApp;
|
|
}
|