mirror of
https://github.com/tale/headplane.git
synced 2026-08-05 11:47:41 +00:00
26 lines
682 B
TypeScript
26 lines
682 B
TypeScript
import { type ActionFunctionArgs, redirect } from "react-router";
|
|
|
|
import type { LoadContext } from "~/server";
|
|
|
|
export async function loader() {
|
|
return redirect("/machines");
|
|
}
|
|
|
|
export async function action({ request, context }: ActionFunctionArgs<LoadContext>) {
|
|
try {
|
|
await context.auth.require(request);
|
|
} catch {
|
|
redirect("/login");
|
|
}
|
|
|
|
// When API key is disabled, we need to explicitly redirect
|
|
// with a logout state to prevent auto login again.
|
|
const url = context.config.oidc?.disable_api_key_login ? "/login?s=logout" : "/login";
|
|
|
|
return redirect(url, {
|
|
headers: {
|
|
"Set-Cookie": await context.auth.destroySession(request),
|
|
},
|
|
});
|
|
}
|