Skip to content

Github issue#277,Changes required for project member invite update endpoint #280

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

Merged
merged 1 commit into from
Mar 20, 2019
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