Skip to content

Commit

Permalink
Merge pull request #764 from OneCommunityGlobal/xiaow_hotfix_of_canno…
Browse files Browse the repository at this point in the history
…t_update_password

XiaoW_Hotfix of cannot update password
  • Loading branch information
one-community authored Feb 23, 2024
2 parents 34b6fb3 + 4891446 commit bb3585c
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/controllers/userProfileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const userProfileController = function (UserProfile) {
cache.setCache('allusers', JSON.stringify(results));
res.status(200).send(results);
})
.catch((error) => res.status(404).send(error));
.catch(error => res.status(404).send(error));
};

const getProjectMembers = async function (req, res) {
Expand Down Expand Up @@ -270,7 +270,7 @@ const userProfileController = function (UserProfile) {
allUserCache.push(userCache);
cache.setCache('allusers', JSON.stringify(allUserCache));
})
.catch((error) => res.status(501).send(error));
.catch(error => res.status(501).send(error));
};

const putUserProfile = async function (req, res) {
Expand Down Expand Up @@ -367,7 +367,7 @@ const userProfileController = function (UserProfile) {
let userIdx;
if (isUserInCache) {
allUserData = JSON.parse(cache.getCache('allusers'));
userIdx = allUserData.findIndex((users) => users._id === userid);
userIdx = allUserData.findIndex(users => users._id === userid);
userData = allUserData[userIdx];
}
if (
Expand Down Expand Up @@ -496,7 +496,7 @@ const userProfileController = function (UserProfile) {
cache.setCache('allusers', JSON.stringify(allUserData));
}
})
.catch((error) => res.status(400).send(error));
.catch(error => res.status(400).send(error));
});
};

Expand Down Expand Up @@ -564,7 +564,7 @@ const userProfileController = function (UserProfile) {

cache.removeCache(`user-${userId}`);
const allUserData = JSON.parse(cache.getCache('allusers'));
const userIdx = allUserData.findIndex((users) => users._id === userId);
const userIdx = allUserData.findIndex(users => users._id === userId);
allUserData.splice(userIdx, 1);
cache.setCache('allusers', JSON.stringify(allUserData));

Expand Down Expand Up @@ -631,7 +631,7 @@ const userProfileController = function (UserProfile) {
res.status(200).send(results);
});
})
.catch((error) => res.status(404).send(error));
.catch(error => res.status(404).send(error));
};

const getUserByName = (req, res) => {
Expand All @@ -643,7 +643,7 @@ const userProfileController = function (UserProfile) {
.then((results) => {
res.status(200).send(results);
})
.catch((error) => res.status(404).send(error));
.catch(error => res.status(404).send(error));
};

const updateOneProperty = function (req, res) {
Expand Down Expand Up @@ -680,9 +680,9 @@ const userProfileController = function (UserProfile) {
.then(() => {
res.status(200).send({ message: 'updated property' });
})
.catch((error) => res.status(500).send(error));
.catch(error => res.status(500).send(error));
})
.catch((error) => res.status(500).send(error));
.catch(error => res.status(500).send(error));
};

const updatepassword = async function (req, res) {
Expand All @@ -706,7 +706,7 @@ const userProfileController = function (UserProfile) {
}
// Check if the requestor has the permission to update passwords.
const hasUpdatePasswordPermission = await hasPermission(
requestor.role,
requestor,
'updatePassword',
);

Expand Down Expand Up @@ -756,11 +756,11 @@ const userProfileController = function (UserProfile) {
return user
.save()
.then(() => res.status(200).send({ message: 'updated password' }))
.catch((error) => res.status(500).send(error));
.catch(error => res.status(500).send(error));
})
.catch((error) => res.status(500).send(error));
.catch(error => res.status(500).send(error));
})
.catch((error) => res.status(500).send(error));
.catch(error => res.status(500).send(error));
};

const getreportees = async function (req, res) {
Expand Down Expand Up @@ -799,7 +799,7 @@ const userProfileController = function (UserProfile) {
});
res.status(200).send(teammembers);
})
.catch((error) => res.status(400).send(error));
.catch(error => res.status(400).send(error));
};

const getTeamMembersofUser = function (req, res) {
Expand All @@ -816,7 +816,7 @@ const userProfileController = function (UserProfile) {
.then((results) => {
res.status(200).send(results);
})
.catch((error) => res.status(400).send(error));
.catch(error => res.status(400).send(error));
};

const getUserName = function (req, res) {
Expand Down Expand Up @@ -873,7 +873,7 @@ const userProfileController = function (UserProfile) {
if (isUserInCache) {
const allUserData = JSON.parse(cache.getCache('allusers'));
const userIdx = allUserData.findIndex(
(users) => users._id === userId,
users => users._id === userId,
);
const userData = allUserData[userIdx];
if (!status) {
Expand Down Expand Up @@ -969,7 +969,7 @@ const userProfileController = function (UserProfile) {
}
res.status(200).send(users);
})
.catch((error) => res.status(500).send(error));
.catch(error => res.status(500).send(error));
};

function escapeRegExp(string) {
Expand All @@ -981,7 +981,7 @@ const userProfileController = function (UserProfile) {
// Creates an array containing the first and last name and filters out whitespace
const fullName = req.params.fullName
.split(' ')
.filter((name) => name !== '');
.filter(name => name !== '');
// Creates a partial match regex for both first and last name
const firstNameRegex = new RegExp(`^${ escapeRegExp(fullName[0])}`, 'i');
const lastNameRegex = new RegExp(`^${ escapeRegExp(fullName[1])}`, 'i');
Expand All @@ -1006,7 +1006,7 @@ const userProfileController = function (UserProfile) {
}
res.status(200).send(users);
})
.catch((error) => res.status(500).send(error));
.catch(error => res.status(500).send(error));
};

return {
Expand Down

0 comments on commit bb3585c

Please sign in to comment.