1bc2de655a
Uniform stock management for healthcare linen rooms. Licensed under the GNU AGPL v3.
17 lines
767 B
TypeScript
17 lines
767 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { clientIp } from "@/lib/ratelimit";
|
|
import { clearOpsCookie, currentOperator, logOperatorEvent } from "@/lib/ops/session";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
/* Ends the operator session. Reached by a plain form post from the console, so it answers with a
|
|
* redirect rather than JSON. Recorded in the trail when there was a session to end. */
|
|
export async function POST(req: NextRequest) {
|
|
const op = await currentOperator();
|
|
if (op) logOperatorEvent({ operatorId: op.id, action: "ops:signout", ip: clientIp(req.headers) });
|
|
await clearOpsCookie();
|
|
const url = req.nextUrl.clone();
|
|
url.pathname = "/ops/login"; url.search = "";
|
|
return NextResponse.redirect(url, { status: 303 });
|
|
}
|