Skip to content

Commit 14a77af

Browse files
author
vikasrohit
authored
Merge pull request #280 from topcoder-platform/hotfix/still_seeing_null_userId_for_invites
Github issue#277,Changes required for project member invite update endpoint
2 parents 26dbdd1 + a9887d8 commit 14a77af

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/routes/projectMemberInvites/update.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,23 @@ module.exports = [
113113
.then((members) => {
114114
req.context = req.context || {};
115115
req.context.currentProjectMembers = members;
116+
let userId = updatedInvite.userId;
117+
// if the requesting user is updating his/her own invite
118+
if (!userId && req.authUser.email === updatedInvite.email) {
119+
userId = req.authUser.userId;
120+
}
121+
// if we are not able to identify the user yet, it must be something wrong and we should not create
122+
// project member
123+
if (!userId) {
124+
const err = new Error(
125+
`Unable to find userId for the invite. ${updatedInvite.email} has not joined topcoder yet.`);
126+
err.status = 400;
127+
return next(err);
128+
}
116129
const member = {
117130
projectId,
118131
role: updatedInvite.role,
119-
userId: _.get(updatedInvite, 'userId', req.authUser.userId),
132+
userId,
120133
createdBy: req.authUser.userId,
121134
updatedBy: req.authUser.userId,
122135
};

0 commit comments

Comments
 (0)