Skip to content

Commit 4207147

Browse files
maxceemMaksym Mykhailenko
and
Maksym Mykhailenko
authored
[HOTFIX] [PROD] Post release 2.3.1 (#550)
* fix: don't mask email in invite by email When user is invited by email he should be able to see email in his invite without mask ref issue #548 * fix: unit tests for invites Co-authored-by: Maksym Mykhailenko <maxcemm@gmail.com>
1 parent 7e3be06 commit 4207147

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/routes/projectMemberInvites/get.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ describe('GET Project Member Invite', () => {
227227
should.exist(resJson);
228228
should.exist(resJson.projectId);
229229
resJson.id.should.be.eql(3);
230-
resJson.email.should.be.eql('t***t@t***r.com'); // masked
230+
// not masked, because user who is invited by email is the user who is calling this endpoint
231+
resJson.email.should.be.eql('test@topcoder.com');
231232
resJson.status.should.be.eql(INVITE_STATUS.PENDING);
232233
done();
233234
}

src/routes/projectMemberInvites/list.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ describe('GET Project Member Invites', () => {
252252
resJson.length.should.be.eql(1);
253253
// check invitations
254254
_.filter(resJson, inv => inv.id === 3).length.should.be.eql(1);
255-
resJson[0].email.should.be.eql('t***t@t***r.com'); // masked
255+
// not masked, because user who is invited by email is the user who is calling this endpoint
256+
resJson[0].email.should.be.eql('test@topcoder.com');
256257
done();
257258
}
258259
});

src/util.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ _.assignIn(util, {
653653

654654
const isAdmin = util.hasPermission({ topcoderRoles: [USER_ROLE.TOPCODER_ADMIN] }, req.authUser);
655655
const currentUserId = req.authUser.userId;
656+
const currentUserEmail = req.authUser.email;
656657

657658
// admins can get data as it is
658659
if (isAdmin) {
@@ -669,7 +670,13 @@ _.assignIn(util, {
669670
const canSeeEmail = (
670671
isAdmin || // admin
671672
invite.createdBy === currentUserId || // user who created invite
672-
invite.userId === currentUserId // user who is invited
673+
(invite.userId !== null && invite.userId === currentUserId) || // user who is invited by `handle`
674+
( // user who is invited by `email` (invite doesn't have `userId`)
675+
invite.userId === null &&
676+
invite.email &&
677+
currentUserEmail &&
678+
invite.email.toLowerCase() === currentUserEmail.toLowerCase()
679+
)
673680
);
674681
// mask email if user cannot see it
675682
_.assign(invite, {

0 commit comments

Comments
 (0)