summaryrefslogtreecommitdiff
path: root/src/lib/server/cookie.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-05-21 14:00:28 +0700
committerpolwex <polwex@sortug.com>2025-05-21 14:00:28 +0700
commite839a5f61f0faa21ca8b4bd5767f7575d5e576ee (patch)
tree53e5bcc3977b6ebef687521a7ac387a89aeb21c8 /src/lib/server/cookie.ts
parent4f2bd597beaa778476b84c10b571db1b13524301 (diff)
the card flip animation is legit
Diffstat (limited to 'src/lib/server/cookie.ts')
-rw-r--r--src/lib/server/cookie.ts52
1 files changed, 23 insertions, 29 deletions
diff --git a/src/lib/server/cookie.ts b/src/lib/server/cookie.ts
index 30f215e..bbabd63 100644
--- a/src/lib/server/cookie.ts
+++ b/src/lib/server/cookie.ts
@@ -1,47 +1,41 @@
-import {
- getCookie,
- getSignedCookie,
- setCookie,
- setSignedCookie,
- deleteCookie,
-} from "hono/cookie";
+import { getHonoContext } from "waku/unstable_hono";
import cookie from "cookie";
-// console.log("db module path:", "@/lib/db");
-// console.log(
-// "globalThis.__WAKU_MIDDLEWARE_CONTEXT_STORAGE__:",
-// globalThis.__WAKU_MIDDLEWARE_CONTEXT_STORAGE__,
-// );
import db from "../db";
import type { Middleware } from "waku/config";
-// XXX we would probably like to extend config.
-
const cookieMiddleware: Middleware = () => {
console.log("cookieMiddleware executed");
return async (ctx, next) => {
const cookies = cookie.parse(ctx.req.headers.cookie || "");
- console.log({ cookies });
const coki = cookies.sorlang;
- if (!coki) {
- if (ctx.req.url.pathname === "/login") return await next();
- ctx.res.status = 301;
- ctx.res.headers = {
- Location: "/login",
- };
- }
+ // if (!coki) {
+ // if (ctx.req.url.pathname === "/login") return await next();
+ // ctx.res.status = 301;
+ // ctx.res.headers = {
+ // Location: "/login",
+ // };
+ // }
if (coki) {
const userRow = db.fetchCookie(coki);
+ console.log({ userRow });
if (userRow) ctx.data.user = { id: userRow.id, name: userRow.name };
- else {
- if (ctx.req.url.pathname === "/login") return await next();
- ctx.res.status = 301;
- ctx.res.headers = {
- Location: "/login",
- };
- }
+ // else {
+ // if (ctx.req.url.pathname === "/login") return await next();
+ // ctx.res.status = 301;
+ // ctx.res.headers = {
+ // Location: "/login",
+ // };
+ // }
}
await next();
+ const hctx: any = getHonoContext();
+ console.log("hono", hctx.lol);
+ console.log("ctx coki", ctx.data.cookie);
+ ctx.res.headers ||= {};
+ if (ctx.data.cookie)
+ ctx.res.headers["set-cookie"] = ctx.data.cookie as string;
+ ctx.res.headers["set-lmao"] = "wtf man";
};
};