diff --git a/backend/app.js b/backend/app.js index d9a2ff5..394f4dc 100644 --- a/backend/app.js +++ b/backend/app.js @@ -2044,7 +2044,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}); @@ -2052,7 +2052,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}); @@ -2060,7 +2060,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});