Skip to content

Commit

Permalink
Merge pull request #2457 from Akhilbisht798/PasswordSetting
Browse files Browse the repository at this point in the history
added setting/resetting password after socail login
  • Loading branch information
raclim authored May 13, 2024
2 parents 9bc4286 + 3e9a151 commit 9e5d1e3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ export async 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) {
const isMatch = await user.comparePassword(req.body.currentPassword);
if (!isMatch) {
Expand Down

0 comments on commit 9e5d1e3

Please sign in to comment.