Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/routes/api.password-policy-remind.tsx
T

24 lines
932 B
TypeScript

import { ActionFunctionArgs } from "react-router";
import { buildRemindCookie } from "~/services/auth/password-policy-banner.server";
import { requireUserId } from "~/utils/session.server";
// Phase 01 / #27 — resource route powering the "Remind me in 7 days"
// button on the password-policy soft-banner. Sets a UX cookie that the
// tenant layout consults before rendering the banner. The cookie is NOT a
// security control — it is purely a dismissal UX, so SameSite=Lax /
// non-httpOnly is fine.
export const action = async ({ request }: ActionFunctionArgs) => {
await requireUserId(request);
return new Response(null, {
status: 204,
headers: {
"Set-Cookie": buildRemindCookie(),
},
});
};
// Defensive: GET requests should not toggle state. Return 405 so the route
// stays POST-only.
export const loader = () =>
new Response("Method Not Allowed", { status: 405, headers: { Allow: "POST" } });