Hooks: Try to refresh the authStore on page reload
This commit is contained in:
@ -2,6 +2,12 @@ import { refresh_auth } from "$lib/pocketbase";
|
|||||||
import type { ClientInit } from "@sveltejs/kit";
|
import type { ClientInit } from "@sveltejs/kit";
|
||||||
|
|
||||||
export const init: ClientInit = async () => {
|
export const init: ClientInit = async () => {
|
||||||
// NOTE: If the auth token is invalidated, this will block the entire page
|
// Try to refresh the authStore. This is required when e.g.
|
||||||
// await refresh_auth();
|
// 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);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user