fix auth issues
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user