Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added setting/resetting password after socail login #2457

Merged
merged 11 commits into from
May 13, 2024
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
Loading