fix: allow logout if auto login if enabled

This commit is contained in:
henrygd
2025-03-05 23:36:57 -05:00
parent 0619eabec2
commit c8130a10d4
2 changed files with 6 additions and 3 deletions

View File

@@ -135,7 +135,6 @@ export function UserAuthForm({
toast({
title: t`Error`,
description: t`Please enable pop-ups for this site`,
variant: "destructive",
})
return
}
@@ -156,8 +155,11 @@ export function UserAuthForm({
useEffect(() => {
// auto login if password disabled and only one auth provider
if (!passwordEnabled && authProviders.length === 1) {
loginWithOauth(authProviders[0], true)
if (!passwordEnabled && authProviders.length === 1 && !sessionStorage.getItem("lo")) {
// Add a small timeout to ensure browser is ready to handle popups
setTimeout(() => {
loginWithOauth(authProviders[0], true)
}, 300)
}
}, [])

View File

@@ -77,6 +77,7 @@ export const updateSystemList = (() => {
/** Logs the user out by clearing the auth store and unsubscribing from realtime updates. */
export async function logOut() {
sessionStorage.setItem("lo", "t")
pb.authStore.clear()
pb.realtime.unsubscribe()
}