fix: only clear auth on 401 or 403, close #1158

This commit is contained in:
Maxi Quoß
2025-05-16 10:18:34 +02:00
parent 1bd2f64729
commit 1bf01cadc7

View File

@@ -59,17 +59,27 @@
await $pocketbase
.collection('_superusers')
.authRefresh()
.catch(() => {
$pocketbase.authStore.clear();
goto('/login');
.catch((err) => {
// clear the store only on invalidated/expired token
const status = err?.status << 0;
if (status == 401 || status == 403) {
$pocketbase.authStore.clear();
goto('/login');
} else {
console.log('NOT CLEARED');
}
});
} else {
await $pocketbase
.collection('users')
.authRefresh()
.catch(() => {
$pocketbase.authStore.clear();
goto('/login');
.catch((err) => {
// clear the store only on invalidated/expired token
const status = err?.status << 0;
if (status == 401 || status == 403) {
$pocketbase.authStore.clear();
goto('/login');
}
});
}
});