feat: add force log out endpoint
This commit is contained in:
parent
c18b79e570
commit
42041d49bc
7 changed files with 72 additions and 15 deletions
|
@ -0,0 +1,19 @@
|
|||
import { ActionFunction, redirect } from "@remix-run/node";
|
||||
import { fastRequest, getToken, writeCookie } from "~/lib/request.server";
|
||||
import { tokenCookieName } from "~/lib/utils";
|
||||
|
||||
export const action: ActionFunction = async ({ request }) => {
|
||||
const token = getToken(request);
|
||||
if (!token)
|
||||
return redirect("/", {
|
||||
status: 303,
|
||||
headers: { "Set-Cookie": writeCookie(tokenCookieName, "token", 0) },
|
||||
});
|
||||
|
||||
await fastRequest("POST", "/internal/force-log-out", { token, isInternal: true });
|
||||
|
||||
return redirect("/", {
|
||||
status: 303,
|
||||
headers: { "Set-Cookie": writeCookie(tokenCookieName, "token", 0) },
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue