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',