From 59318331cfb68260e56fcfc6917a0d5fee2b20d0 Mon Sep 17 00:00:00 2001 From: Arc <90333108+lastarc@users.noreply.github.com> Date: Fri, 19 Jul 2024 23:44:40 +0200 Subject: [PATCH] fix(auth): clear authStore on refresh failure --- src/routes/+layout.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 3900880..46a7145 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -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;