Hooks: Try to refresh the authStore on page reload

This commit is contained in:
2025-03-15 00:19:14 +01:00
parent e35d56c81c
commit 62f4d211ac

View File

@ -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);
}
};