Fix Linux auth: Use signInWithRedirect fallback
This commit is contained in:
parent
ff7b17b4eb
commit
e9e37c9be1
2 changed files with 27 additions and 1 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
import { auth, provider } from './config.js';
|
import { auth, provider } from './config.js';
|
||||||
import {
|
import {
|
||||||
signInWithPopup,
|
signInWithPopup,
|
||||||
|
signInWithRedirect,
|
||||||
|
getRedirectResult,
|
||||||
signOut as firebaseSignOut,
|
signOut as firebaseSignOut,
|
||||||
onAuthStateChanged,
|
onAuthStateChanged,
|
||||||
signInWithEmailAndPassword,
|
signInWithEmailAndPassword,
|
||||||
|
|
@ -26,6 +28,12 @@ export class AuthManager {
|
||||||
|
|
||||||
this.authListeners.forEach((listener) => listener(user));
|
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) {
|
onAuthStateChanged(callback) {
|
||||||
|
|
@ -43,11 +51,29 @@ export class AuthManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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);
|
const result = await signInWithPopup(auth, provider);
|
||||||
// The onAuthStateChanged listener will handle the rest
|
// The onAuthStateChanged listener will handle the rest
|
||||||
return result.user;
|
return result.user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Login failed:', 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}`);
|
alert(`Login failed: ${error.message}`);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -514,7 +514,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
ui.setCurrentTrack(player.currentTrack);
|
ui.setCurrentTrack(player.currentTrack);
|
||||||
|
|
||||||
// Update Media Session with new track
|
// Update Media Session with new track
|
||||||
updateMediaMetadata(player.currentTrack);
|
player.updateMediaSession(player.currentTrack);
|
||||||
|
|
||||||
const currentTrackId = player.currentTrack.id;
|
const currentTrackId = player.currentTrack.id;
|
||||||
if (currentTrackId === previousTrackId) return;
|
if (currentTrackId === previousTrackId) return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue