ls-deno/routes/logout.tsx
2022-10-12 03:31:26 -05:00

26 lines
734 B
TypeScript

import { Handlers } from "$fresh/server.ts";
// import { getToken, getUser } from "@/db/mod.ts";
// import * as base64 from "$std/encoding/base64.ts";
import { deleteCookie, getCookies } from "$std/http/cookie.ts";
import { deleteToken } from "@/db/mod.ts";
export const handler: Handlers<unknown> = {
async GET(request: Request, context) {
const { lsauth } = getCookies(request.headers);
if (lsauth) {
console.log("deleteToken:", await deleteToken(lsauth));
}
const response = await context.render();
deleteCookie(response.headers, "lsauth");
return response;
},
};
export default function LoggedOut() {
return (
<p>
If you were logged in before, we've logged you out.
</p>
);
}