From 945bf269d7b0c8f8b5245475398694378b74b25f Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 4 Nov 2025 10:44:22 -0800 Subject: add bio for profile page --- backend/schema.prisma | 1 + backend/src/routes/user.ts | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'backend') diff --git a/backend/schema.prisma b/backend/schema.prisma index 3dda29d..fbc2f90 100644 --- a/backend/schema.prisma +++ b/backend/schema.prisma @@ -13,6 +13,7 @@ model User { password String salt String email String @unique + bio String? sessions Session[] scores Score[] isAdmin Boolean diff --git a/backend/src/routes/user.ts b/backend/src/routes/user.ts index fc03e68..497d6da 100644 --- a/backend/src/routes/user.ts +++ b/backend/src/routes/user.ts @@ -4,12 +4,13 @@ import { prisma } from '../config/db'; export const handleMeRoute = async (req: express.Request, res: express.Response) => { try { - if (!req.session.userId) { - return res.status(403).json({ error: 'Not Authenticated' }); + const { userId } = req.query; + if (!userId) { + return res.status(400).json({ error: 'userId query parameter is required' }); } const user = await prisma.user.findUniqueOrThrow({ - where: { id: req.session.userId }, - select: { id: true, username: true, isAdmin: true } + where: { id: parseInt(userId as string) }, + select: { id: true, username: true, isAdmin: true, bio: true } }); const isAdmin = user.id === 1 || user.isAdmin; res.json({user, isAdmin}); -- cgit v1.2.3