diff --git a/.env.example b/.env.example index 0d1fd65..d51cf88 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,9 @@ MONOCHROME_DEV_PORT=5173 AUTH_ENABLED=false AUTH_SECRET=change-me-to-a-random-string FIREBASE_PROJECT_ID=monochrome-database +# Optional: toggle login providers (defaults to true when unset) +# AUTH_GOOGLE_ENABLED=true +# AUTH_EMAIL_ENABLED=true # Optional: override the Firebase config for the login page (JSON string) # FIREBASE_CONFIG={"apiKey":"...","authDomain":"...","projectId":"...","storageBucket":"...","messagingSenderId":"...","appId":"..."} # Optional: set PocketBase URL (hides the field in settings when set) diff --git a/AUTH_GATE.md b/AUTH_GATE.md index 51464f8..7c02eb9 100644 --- a/AUTH_GATE.md +++ b/AUTH_GATE.md @@ -27,6 +27,8 @@ This document explains the optional server-side login gate and what it implies f - `AUTH_ENABLED=true` enables the gate (default is false). - `AUTH_SECRET` is required when the gate is enabled. It signs the session cookie. +- `AUTH_GOOGLE_ENABLED` toggles Google sign-in on `/login` (default true). +- `AUTH_EMAIL_ENABLED` toggles email/password sign-in on `/login` (default true). - `FIREBASE_PROJECT_ID` sets the Firebase project used to verify tokens. - `FIREBASE_CONFIG` (JSON) injects config into the login page. - `POCKETBASE_URL` hides the custom DB setting field. diff --git a/js/accounts/auth.js b/js/accounts/auth.js index 84a9351..13b29db 100644 --- a/js/accounts/auth.js +++ b/js/accounts/auth.js @@ -61,6 +61,23 @@ export class AuthManager { return; } + // Check for Neutralino mode + const isNeutralino = + window.NL_MODE || + window.location.search.includes('mode=neutralino') || + (window.Neutralino && typeof window.Neutralino === 'object'); + + if (isNeutralino) { + try { + await signInWithRedirect(auth, provider); + return; + } catch (error) { + console.error('Redirect Login failed:', error); + alert(`Login failed: ${error.message}`); + throw error; + } + } + try { const result = await signInWithPopup(auth, provider); diff --git a/js/app.js b/js/app.js index 8cd3ae2..17424e6 100644 --- a/js/app.js +++ b/js/app.js @@ -265,7 +265,13 @@ document.addEventListener('DOMContentLoaded', async () => { initTracker(player); // Initialize desktop features if in Neutralino mode - if (typeof window !== 'undefined' && (window.NL_MODE || window.location.search.includes('mode=neutralino'))) { + if ( + typeof window !== 'undefined' && + (window.NL_MODE || + window.location.search.includes('mode=neutralino') || + (window.Neutralino && typeof window.Neutralino === 'object')) + ) { + window.NL_MODE = true; import('./desktop/desktop.js').then((m) => m.initDesktop(player)); } diff --git a/package.json b/package.json index 7c797a5..3b8fb26 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "description": "[\"Monochrome](https://monochrome.samidy.com)", "main": "sw.js", "scripts": { + "preview": "vite preview", + "start": "vite preview", "dev": "vite", "dev:desktop": "start npm run dev & node scripts/dev-runner.js", "build": "vite build --mode neutralino && bun x neu build", diff --git a/public/login.html b/public/login.html index e3a1ccd..6b1c04d 100644 --- a/public/login.html +++ b/public/login.html @@ -183,7 +183,7 @@
-