Skip to content

Commit 33bdb8a

Browse files
committed
feat: always return email of invites to the users who invited user by email
ref issue #3412
1 parent daec450 commit 33bdb8a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/routes/projectMemberInvites/create.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,11 @@ module.exports = [
366366
})
367367
))
368368
.then((values) => {
369-
const success = _.assign({}, { success: values });
369+
const response = _.assign({}, { success: values });
370370
if (failed.length) {
371-
res.status(403).json(_.assign({}, util.maskInviteEmails('$.success[?(@.email)]', success, req), { failed }));
371+
res.status(403).json(_.assign({}, response, { failed }));
372372
} else {
373-
res.status(201).json(util.maskInviteEmails('$.success[?(@.email)]', success, req));
373+
res.status(201).json(response);
374374
}
375375
})
376376
.catch(err => next(err));

src/routes/projectMemberInvites/create.spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ describe('Project Member Invite create', () => {
347347
should.exist(resJson);
348348
resJson.role.should.equal('customer');
349349
resJson.projectId.should.equal(project2.id);
350-
// temporary disable this feature, because it has some side effects
351-
// resJson.email.should.equal('he**o@wo**d.com'); // email is masked
352350
resJson.email.should.equal('hello@world.com');
353351
server.services.pubsub.publish.calledWith('project.member.invite.created').should.be.true;
354352
done();
@@ -401,8 +399,6 @@ describe('Project Member Invite create', () => {
401399
resJson.role.should.equal('customer');
402400
resJson.projectId.should.equal(project2.id);
403401
resJson.userId.should.equal(12345);
404-
// temporary disable this feature, because it has some side effects
405-
// resJson.email.should.equal('he**o@wo**d.com'); // email is masked
406402
resJson.email.should.equal('hello@world.com');
407403
server.services.pubsub.publish.calledWith('project.member.invite.created').should.be.true;
408404
done();

src/util.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,9 +728,14 @@ _.assignIn(util, {
728728
// in general, only users with Topcoder administrator privileges can see emails
729729
let canSeeEmail = util.hasPermission({ topcoderRoles: [USER_ROLE.TOPCODER_ADMIN] }, req.authUser);
730730

731-
// specially for invite objects, we still have to return email, if invite is for a new user which doesn't have "userId"
731+
// for invites we have some special situations, when we still return "email"
732732
if (memberDetails.status) { // we identify that the object is "invite" and not a "member" if object has "status" field
733+
// we still have to return email, if invite is for a new user which doesn't have "userId"
733734
canSeeEmail = canSeeEmail || !memberDetails.userId;
735+
736+
// return email, if invite has been created by "email" by the current user
737+
// so this user already knows the "email"
738+
canSeeEmail = canSeeEmail || (member.createdBy === req.authUser.userId && member.email);
734739
}
735740

736741
if (!canSeeEmail) {

0 commit comments

Comments
 (0)