Skip to content

Commit

Permalink
prevent demo account change
Browse files Browse the repository at this point in the history
  • Loading branch information
salahlalami committed Oct 2, 2024
1 parent 1d98406 commit 36b1d5e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ const updatePassword = async (userModel, req, res) => {

// Find document by id and updates with the required fields

if (userProfile.email === 'admin@demo.com') {
return res.status(403).json({
success: false,
result: null,
message: "you couldn't update demo password",
});
}

const salt = uniqueId();

const passwordHash = bcrypt.hashSync(salt + password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ const updateProfile = async (userModel, req, res) => {

const reqUserName = userModel.toLowerCase();
const userProfile = req[reqUserName];

if (userProfile.email === 'admin@demo.com') {
return res.status(403).json({
success: false,
result: null,
message: "you couldn't update demo informations",
});
}

let updates = req.body.photo
? {
email: req.body.email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ const updateProfilePassword = async (userModel, req, res) => {
salt: salt,
};

if (userProfile.email === 'admin@demo.com') {
return res.status(403).json({
success: false,
result: null,
message: "you couldn't update demo password",
});
}
const resultPassword = await UserPassword.findOneAndUpdate(
{ user: userProfile._id, removed: false },
{ $set: UserPasswordData },
Expand Down

0 comments on commit 36b1d5e

Please sign in to comment.