Skip to content

Commit 5931833

Browse files
committed
fix(auth): clear authStore on refresh failure
1 parent 29630c6 commit 5931833

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/routes/+layout.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import type { LayoutLoad } from './$types';
22
import { pb } from '$lib/pocketbase';
33
import type { RecordModel } from 'pocketbase';
44

5-
export const load: LayoutLoad = async ({ setHeaders }) => {
5+
export const load: LayoutLoad = async () => {
66
pb.authStore.loadFromCookie(document.cookie);
77

88
try {
99
pb.authStore.isValid && (await pb.collection('users').authRefresh());
10-
} catch (e) {
11-
console.log('authRefresh error', e);
12-
// do nothing
10+
} catch (_) {
11+
pb.authStore.clear();
1312
}
1413

1514
const user = pb.authStore.model;

0 commit comments

Comments
 (0)