From 6400b807c212dba5c16af840e94ff8db6263d21d Mon Sep 17 00:00:00 2001 From: Tzahi12345 Date: Mon, 17 Apr 2023 23:54:34 -0400 Subject: [PATCH] Fixed auth error in notifications --- backend/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/app.js b/backend/app.js index 36519bc..2b6ba9e 100644 --- a/backend/app.js +++ b/backend/app.js @@ -2040,7 +2040,7 @@ app.post('/api/getNotifications', optionalJwt, async (req, res) => { // set notifications to read app.post('/api/setNotificationsToRead', optionalJwt, async (req, res) => { - const uuid = req.user.uid; + const uuid = req.isAuthenticated() ? req.user.uid : null; const success = await db_api.updateRecords('notifications', {user_uid: uuid}, {read: true}); @@ -2048,7 +2048,7 @@ app.post('/api/setNotificationsToRead', optionalJwt, async (req, res) => { }); app.post('/api/deleteNotification', optionalJwt, async (req, res) => { - const uid = req.body.uid; + const uid = req.isAuthenticated() ? req.user.uid : null; const success = await db_api.removeRecord('notifications', {uid: uid}); @@ -2056,7 +2056,7 @@ app.post('/api/deleteNotification', optionalJwt, async (req, res) => { }); app.post('/api/deleteAllNotifications', optionalJwt, async (req, res) => { - const uuid = req.user.uid; + const uuid = req.isAuthenticated() ? req.user.uid : null; const success = await db_api.removeAllRecords('notifications', {user_uid: uuid});