Fix Linux auth: Use signInWithRedirect fallback

This commit is contained in:
Julien Maille 2026-02-07 22:59:03 +01:00
parent ff7b17b4eb
commit e9e37c9be1
2 changed files with 27 additions and 1 deletions

View file

@ -2,6 +2,8 @@
import { auth, provider } from './config.js';
import {
signInWithPopup,
signInWithRedirect,
getRedirectResult,
signOut as firebaseSignOut,
onAuthStateChanged,
signInWithEmailAndPassword,
@ -26,6 +28,12 @@ export class AuthManager {
this.authListeners.forEach((listener) => listener(user));
});
// Handle redirect result (for Linux/Mobile where popup might be blocked)
getRedirectResult(auth).catch((error) => {
console.error('Redirect Login failed:', error);
alert(`Login failed: ${error.message}`);
});
}
onAuthStateChanged(callback) {
@ -43,11 +51,29 @@ export class AuthManager {
}
try {
// Check for Linux environment (Neutralino) where popups are often blocked
if (window.NL_OS === 'Linux') {
await signInWithRedirect(auth, provider);
// The page will redirect, so no return value needed immediately
return;
}
const result = await signInWithPopup(auth, provider);
// The onAuthStateChanged listener will handle the rest
return result.user;
} catch (error) {
console.error('Login failed:', error);
if (error.code === 'auth/popup-blocked') {
console.log('Popup blocked, falling back to redirect...');
try {
await signInWithRedirect(auth, provider);
return;
} catch (redirectError) {
console.error('Redirect fallback failed:', redirectError);
alert(`Login failed: ${redirectError.message}`);
throw redirectError;
}
}
alert(`Login failed: ${error.message}`);
throw error;
}

View file

@ -514,7 +514,7 @@ document.addEventListener('DOMContentLoaded', async () => {
ui.setCurrentTrack(player.currentTrack);
// Update Media Session with new track
updateMediaMetadata(player.currentTrack);
player.updateMediaSession(player.currentTrack);
const currentTrackId = player.currentTrack.id;
if (currentTrackId === previousTrackId) return;