Skip to content

Commit

Permalink
Merge pull request #5 from lastarc/clear-authstore-on-refresh-failure
Browse files Browse the repository at this point in the history
fix(auth): clear authStore on refresh failure
  • Loading branch information
lastarc authored Jul 19, 2024
2 parents 29630c6 + 5931833 commit aaede0c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import type { LayoutLoad } from './$types';
import { pb } from '$lib/pocketbase';
import type { RecordModel } from 'pocketbase';

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

try {
pb.authStore.isValid && (await pb.collection('users').authRefresh());
} catch (e) {
console.log('authRefresh error', e);
// do nothing
} catch (_) {
pb.authStore.clear();
}

const user = pb.authStore.model;
Expand Down

0 comments on commit aaede0c

Please sign in to comment.