fix login bug
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { createPbClient } from '$lib/server/pocketbase';
|
||||
import { createServices, type ChatActor } from '$lib/server/services';
|
||||
import { ensureFamAccess } from '$lib/server/access';
|
||||
@@ -63,6 +64,17 @@ export async function load(event) {
|
||||
fam = res.fam;
|
||||
famAccess = res.access;
|
||||
}
|
||||
// Canonical URL: the [fam] segment must be the family SLUG, never the PB
|
||||
// id. If someone lands on /{famId}/... (a stale shortcut, bookmark, or a
|
||||
// login that fell back to the id), rewrite the first path segment to the
|
||||
// slug so the id is replaced everywhere it'd otherwise persist.
|
||||
const paramFam = event.params.fam;
|
||||
const canonicalSlug = fam?.slug;
|
||||
if (canonicalSlug && paramFam && paramFam !== canonicalSlug) {
|
||||
const rest = event.url.pathname.replace(`/${paramFam}`, '') || '/';
|
||||
const qs = event.url.search;
|
||||
throw redirect(303, `/${encodeURIComponent(canonicalSlug)}${rest}${qs}`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user