fix auth issues

This commit is contained in:
JCEEE
2026-09-16 21:07:21 +01:00
parent 812f6a4f88
commit 9566506d30
4 changed files with 85 additions and 3 deletions
+15 -2
View File
@@ -30,8 +30,21 @@ export const actions = {
// An explicit email/password login supersedes kid mode on a shared device.
clearActiveChild(event.cookies);
const fam = await pbAdmin.getOne('fams', user.famId).catch(() => null);
const famSlug = fam?.slug || user.famId;
// Fam lookup with retries: right after a deploy/rebuild PB can blip and
// a single failed fetch falls back to the raw fam ID in the URL
// (/{famId}/...), which then persists via bookmarks/shortcuts.
let fam: any = null;
for (let i = 0; i < 4 && !fam; i++) {
if (i > 0) await new Promise((r) => setTimeout(r, 500 * i));
fam = await pbAdmin.getOne('fams', user.famId).catch(() => null);
}
if (!fam) {
return fail(503, {
error: 'Family data is briefly unavailable (server restarting). Please try again.',
email
});
}
const famSlug = fam.slug;
// Parents (admins) land on the fam dashboard — no username in the URL.
if (user.role === 'parent') {