From e36a3f391fe77b775bc2f95c9c34d8d71c2a7ab8 Mon Sep 17 00:00:00 2001 From: Akhilbisht798 Date: Mon, 18 Sep 2023 22:56:39 +0530 Subject: [PATCH] added setting/resetting password after socail login --- server/controllers/user.controller.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/controllers/user.controller.js b/server/controllers/user.controller.js index bc3e179662..277180b448 100644 --- a/server/controllers/user.controller.js +++ b/server/controllers/user.controller.js @@ -344,6 +344,16 @@ export function updateSettings(req, res) { user.username = req.body.username; + if (req.body.newPassword) { + if (user.password === undefined) { + user.password = req.body.newPassword; + saveUser(res, user); + } + if (!req.body.currentPassword) { + res.status(401).json({ error: 'Current password is not provided.' }); + return; + } + } if (req.body.currentPassword) { user.comparePassword(req.body.currentPassword, (passwordErr, isMatch) => { if (passwordErr) throw passwordErr;