Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 18x 18x 18x 9x 18x 18x | import { getSession } from "@/lib/auth";
import { permanentRedirect, redirect } from "next/navigation";
import { getDb } from "@/lib/db";
import { requireCollectionAccess } from "@/lib/collection-access";
/**
* Retired collection pages (spec §4, §5) bounce old links here. The access guard runs
* FIRST — page-authz-enumeration expects the stranger's redirect to be the first
* throw — then a permanent (308) move to the home (""), the Sort screen or the Ranking.
*/
export async function redirectRetired(
id: string,
to: "" | "sort" | "results",
query?: URLSearchParams,
): Promise<never> {
const session = await getSession();
Iif (!session?.user) {
redirect("/login");
}
const collection = await requireCollectionAccess(getDb(), id, session.user.id);
const path = `/collections/${collection.slug ?? collection.id}${to ? `/${to}` : ""}`;
const qs = query?.toString();
permanentRedirect(qs ? `${path}?${qs}` : path);
}
|