auth: ensure realtime subscriptions are cleared on logout

This commit is contained in:
Henry Dollman
2025-02-05 20:24:39 -05:00
parent 2216e40f04
commit 1daf35406a
2 changed files with 8 additions and 3 deletions

View File

@@ -33,7 +33,7 @@ const verifyAuth = () => {
pb.collection("users")
.authRefresh()
.catch(() => {
pb.authStore.clear()
logOut()
toast({
title: t`Failed to authenticate`,
description: t`Please log in again`,
@@ -65,6 +65,11 @@ export const updateSystemList = (() => {
}
})()
/** Logs the user out by clearing the auth store and unsubscribing from realtime updates. */
export async function logOut() {
pb.authStore.clear()
pb.realtime.unsubscribe()
}
export const updateAlerts = () => {
pb.collection("alerts")