From 16a32842e2d824c1cdea4956533b5ebcec5d6496 Mon Sep 17 00:00:00 2001 From: Dunsin Date: Mon, 12 Aug 2024 14:24:37 +0100 Subject: [PATCH] fix: add checker if userToDelete is not null --- server/utils/lib.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/utils/lib.js b/server/utils/lib.js index eee78488..328a5eea 100644 --- a/server/utils/lib.js +++ b/server/utils/lib.js @@ -130,7 +130,10 @@ async function delActiveUser(user) { delete activeUsers[user.emailOrLoginId]; const userToDelete = await ActiveUser.findById(user.id); - if (!userToDelete.email) { + if ( + userToDelete && + (!userToDelete.email || userToDelete.email.trim() === '') + ) { await ActiveUser.deleteOne({ _id: user.id }); } }