Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/routes/projectMemberInvites/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,23 @@ module.exports = [
.then((members) => {
req.context = req.context || {};
req.context.currentProjectMembers = members;
let userId = updatedInvite.userId;
// if the requesting user is updating his/her own invite
if (!userId && req.authUser.email === updatedInvite.email) {
userId = req.authUser.userId;
}
// if we are not able to identify the user yet, it must be something wrong and we should not create
// project member
if (!userId) {
const err = new Error(
`Unable to find userId for the invite. ${updatedInvite.email} has not joined topcoder yet.`);
err.status = 400;
return next(err);
}
const member = {
projectId,
role: updatedInvite.role,
userId: _.get(updatedInvite, 'userId', req.authUser.userId),
userId,
createdBy: req.authUser.userId,
updatedBy: req.authUser.userId,
};
Expand Down