22 lines
1.1 KiB
TypeScript
22 lines
1.1 KiB
TypeScript
import { redirect, type ActionFunctionArgs, type LoaderFunctionArgs } from "react-router";
|
|
|
|
import { validatePortalCsrfToken } from "~/services/customer-portal/portal-csrf.server";
|
|
import { portalNotFound, requirePortalSessionIdentity, revokePortalSession } from "~/services/customer-portal/portal-data.server";
|
|
import { clearPortalSessionCookie } from "~/services/customer-portal/portal-session-cookie.server";
|
|
import { portalPublicPath, requireTrustedPortalOrigin } from "~/services/customer-portal/portal-origin.server";
|
|
|
|
export async function loader(_args: LoaderFunctionArgs) {
|
|
throw portalNotFound();
|
|
}
|
|
|
|
export async function action({ request, params }: ActionFunctionArgs) {
|
|
const form = await request.clone().formData();
|
|
await validatePortalCsrfToken(request, form);
|
|
const identity = await requirePortalSessionIdentity(request, params.tenant);
|
|
const origin = requireTrustedPortalOrigin(request, identity.tenantSlug);
|
|
await revokePortalSession(identity, request);
|
|
throw redirect(portalPublicPath(origin, "login"), {
|
|
headers: { "Cache-Control": "no-store", "Set-Cookie": await clearPortalSessionCookie() },
|
|
});
|
|
}
|