From f16980969239bc88a8a69896652ddf278098393e Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 16 Jul 2024 14:40:37 -0700 Subject: [PATCH] Fixed token issue --- Server/controllers/authController.js | 5 +++-- Server/db/MongoDB.js | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Server/controllers/authController.js b/Server/controllers/authController.js index 51ee2dac1..1cab8703e 100644 --- a/Server/controllers/authController.js +++ b/Server/controllers/authController.js @@ -309,11 +309,12 @@ const validateRecoveryTokenController = async (req, res, next) => { const resetPasswordController = async (req, res, next) => { try { await newPasswordValidation.validateAsync(req.body); - const response = await req.db.resetPassword(req, res); + const user = await req.db.resetPassword(req, res); + const token = issueToken(user); res.status(200).json({ success: true, msg: successMessages.AUTH_RESET_PASSWORD, - data: response, + data: { user, token }, }); } catch (error) { error.service = SERVICE_NAME; diff --git a/Server/db/MongoDB.js b/Server/db/MongoDB.js index 4b225b543..c0b0948a2 100644 --- a/Server/db/MongoDB.js +++ b/Server/db/MongoDB.js @@ -220,8 +220,7 @@ const resetPassword = async (req, res) => { }) .select("-password") .select("-profileImage"); - const token = issueToken(userWithoutPassword); - return { user: userWithoutPassword, token: token }; + return userWithoutPassword; } else { throw new Error(errorMessages.DB_USER_NOT_FOUND); }