From d25ec6ebe761dfa8cf089127c308d3aecb6aaa28 Mon Sep 17 00:00:00 2001 From: Esteban Date: Mon, 2 Feb 2026 00:58:35 -0600 Subject: [PATCH] fix: correct req.user property from id to userId in controllers --- water-api/src/controllers/meter.controller.ts | 2 +- water-api/src/controllers/project.controller.ts | 2 +- water-api/src/controllers/user.controller.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/water-api/src/controllers/meter.controller.ts b/water-api/src/controllers/meter.controller.ts index b4a981b..b7c0ac1 100644 --- a/water-api/src/controllers/meter.controller.ts +++ b/water-api/src/controllers/meter.controller.ts @@ -89,7 +89,7 @@ export async function getById(req: Request, res: Response): Promise { */ export async function create(req: AuthenticatedRequest, res: Response): Promise { try { - const userId = req.user?.id; + const userId = req.user?.userId; if (!userId) { res.status(401).json({ diff --git a/water-api/src/controllers/project.controller.ts b/water-api/src/controllers/project.controller.ts index 64e12ec..d1c001e 100644 --- a/water-api/src/controllers/project.controller.ts +++ b/water-api/src/controllers/project.controller.ts @@ -81,7 +81,7 @@ export async function getById(req: Request, res: Response): Promise { */ export async function create(req: AuthenticatedRequest, res: Response): Promise { try { - const userId = req.user?.id; + const userId = req.user?.userId; if (!userId) { res.status(401).json({ diff --git a/water-api/src/controllers/user.controller.ts b/water-api/src/controllers/user.controller.ts index a60f703..a028b50 100644 --- a/water-api/src/controllers/user.controller.ts +++ b/water-api/src/controllers/user.controller.ts @@ -254,7 +254,7 @@ export async function deleteUser( } // Prevent admin from deleting themselves - if (req.user?.id === userId) { + if (req.user?.userId === userId) { res.status(400).json({ success: false, error: 'Cannot deactivate your own account', @@ -305,7 +305,7 @@ export async function changePassword( } // Only allow users to change their own password - if (req.user?.id !== userId) { + if (req.user?.userId !== userId) { res.status(403).json({ success: false, error: 'You can only change your own password',