mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-21 06:29:29 -05:00
17 lines
488 B
TypeScript
17 lines
488 B
TypeScript
import type { LoaderFunction } from "@remix-run/node";
|
|
import { redirect } from "@remix-run/node";
|
|
import { getUserId, isImpersonating } from "~/features/auth/core/user.server";
|
|
import { isMod } from "~/permissions";
|
|
|
|
export const loader: LoaderFunction = async ({ request }) => {
|
|
const user = await getUserId(request);
|
|
|
|
if (process.env.NODE_ENV === "production" && !isMod(user)) {
|
|
throw redirect("/");
|
|
}
|
|
|
|
return {
|
|
isImpersonating: await isImpersonating(request),
|
|
};
|
|
};
|