feat: refactoring, soem work on forms
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
import { deleteCookie, getCookies, setCookie } from "@std/http/cookie";
|
||||
|
||||
export function setAuthCookie(
|
||||
headers: Headers,
|
||||
) {
|
||||
setCookie(headers, {
|
||||
name: "auth",
|
||||
value: "ok",
|
||||
maxAge: 60 * 60,
|
||||
sameSite: "Lax",
|
||||
path: "/",
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
});
|
||||
}
|
||||
|
||||
export function unsetAuthCookie(headers: Headers) {
|
||||
deleteCookie(headers, "auth", {
|
||||
path: "/",
|
||||
});
|
||||
}
|
||||
|
||||
export function isLoggedIn(req: Request): boolean {
|
||||
const cookies = getCookies(req.headers);
|
||||
const authCookie = cookies["auth"];
|
||||
return authCookie === "ok";
|
||||
}
|
||||
Reference in New Issue
Block a user