all repos — stealth-developers @ d50a9160254db7ccf1b406556ecb9eb21de84383

feat(frontend): wait for auth
vi did:web:vt3e.cat
Sat, 09 May 2026 04:36:09 +0100
commit

d50a9160254db7ccf1b406556ecb9eb21de84383

parent

f6f5a6423298aebc9c56231c1a1ec8c68895f891

2 files changed, 12 insertions(+), 2 deletions(-)

jump to
M frontend/src/router/index.tsfrontend/src/router/index.ts

@@ -28,8 +28,11 @@ },

], }); -router.beforeEach((to, _from, next) => { - const isAuthenticated = useAuthStore().isAuthenticated; +router.beforeEach(async (to, _from, next) => { + const authStore = useAuthStore(); + await authStore.waitForAuth(); + const isAuthenticated = authStore.isAuthenticated; + if (to.name !== "Login" && !isAuthenticated) { next({ name: "Login" }); } else {
M frontend/src/stores/auth.tsfrontend/src/stores/auth.ts

@@ -15,9 +15,16 @@ isAuthenticated.value = true;

} catch {} } + async function waitForAuth() { + while (!isAuthenticated.value) { + await getUser(); + } + } + return { isAuthenticated, user, getUser, + waitForAuth, }; });