Skip to content

Commit

Permalink
easy
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed Nov 22, 2024
1 parent 67f5907 commit 140970c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/server/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { decrypt } from "@/lib/jwt";
import { serverEnv } from "@/utils/env/server";
import { User } from "@prisma/client";
import { Elysia, InternalServerError } from "elysia";
import { cookies } from "next/headers";

/**
* User route for retrieving the current user's information.
Expand All @@ -12,7 +13,9 @@ export const userRoute = new Elysia({ prefix: "/user" }).get(
"/me",
async (ctx) => {
// Decrypt user information from the authentication jwt cookie
const user = await decrypt<User>(ctx.cookie[serverEnv.AUTH_COOKIE].value);
const user = await decrypt<User>(
(await cookies()).get(serverEnv.AUTH_COOKIE)?.value,
);

if (!user) throw new InternalServerError("User not found");

Expand Down

0 comments on commit 140970c

Please sign in to comment.