From 62f4d211ac860932d30278245dd304a62c9c2c41 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sat, 15 Mar 2025 00:19:14 +0100 Subject: [PATCH] Hooks: Try to refresh the authStore on page reload --- src/hooks.client.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hooks.client.ts b/src/hooks.client.ts index 3af4709..ffd1e9f 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -2,6 +2,12 @@ import { refresh_auth } from "$lib/pocketbase"; import type { ClientInit } from "@sveltejs/kit"; export const init: ClientInit = async () => { - // NOTE: If the auth token is invalidated, this will block the entire page - // await refresh_auth(); + // Try to refresh the authStore. This is required when e.g. + // changing e-mail address. The new e-mail will show up after + // being verified, so the authStore has to be reloaded. + try { + await refresh_auth(); + } catch (error) { + console.log("hooks.client.ts:", error); + } };