diff --git a/src/features/auth/server/route.ts b/src/features/auth/server/route.ts index a51c70e..33b914a 100644 --- a/src/features/auth/server/route.ts +++ b/src/features/auth/server/route.ts @@ -5,8 +5,14 @@ import { zValidator } from "@hono/zod-validator"; import { createAdminClient } from "@/lib/appwrite"; import { deleteCookie, setCookie } from "hono/cookie"; import { loginSchema, registerSchema } from "../schema"; +import { sessionMiddleware } from "@/lib/session-middleware"; const app = new Hono() + .get("/current", sessionMiddleware, (c) => { + const user = c.get("user"); + + return c.json({ data: user }); + }) .post("/login", zValidator("json", loginSchema), async (c) => { const { email, password } = c.req.valid("json"); @@ -41,8 +47,11 @@ const app = new Hono() return c.json({ success: true }); }) - .post("/logout", (c) => { + .post("/logout", sessionMiddleware, async (c) => { + const account = c.get("account"); + deleteCookie(c, AUTH_COOKIE); + await account.deleteSession("current"); return c.json({ success: true }); });