File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed
routes/projectMemberInvites Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -445,9 +445,8 @@ describe('Project Member Invite create', () => {
445
445
should . exist ( resJson ) ;
446
446
resJson . role . should . equal ( 'customer' ) ;
447
447
resJson . projectId . should . equal ( project2 . id ) ;
448
- resJson . userId . should . equal ( 12345 ) ;
449
- should . not . exist ( resJson . email ) ;
450
- should . not . exist ( resJson . hashEmail ) ;
448
+ should . not . exist ( resJson . userId ) ;
449
+ resJson . email . should . equal ( 'hello@world.com' ) ;
451
450
server . services . pubsub . publish . calledWith ( 'project.member.invite.created' ) . should . be . true ;
452
451
done ( ) ;
453
452
}
Original file line number Diff line number Diff line change @@ -206,10 +206,7 @@ describe('GET Project Member Invite', () => {
206
206
const resJson = res . body ;
207
207
should . exist ( resJson ) ;
208
208
should . exist ( resJson . projectId ) ;
209
- should . not . exist ( resJson . email ) ;
210
- should . not . exist ( resJson . hashEmail ) ;
211
209
resJson . id . should . be . eql ( 2 ) ;
212
- resJson . userId . should . be . eql ( testUtil . userIds . copilot ) ;
213
210
resJson . status . should . be . eql ( INVITE_STATUS . PENDING ) ;
214
211
done ( ) ;
215
212
}
Original file line number Diff line number Diff line change @@ -659,6 +659,7 @@ _.assignIn(util, {
659
659
const isAdmin = util . hasPermission ( { topcoderRoles : [ USER_ROLE . TOPCODER_ADMIN ] } , req . authUser ) ;
660
660
const currentUserId = req . authUser . userId ;
661
661
662
+ // admins can get data as it is
662
663
if ( isAdmin ) {
663
664
// even though we didn't make any changes to the data, return a clone here for consistency
664
665
return dataClone ;
@@ -668,18 +669,21 @@ _.assignIn(util, {
668
669
if ( ! _ . has ( invite , 'email' ) ) {
669
670
return invite ;
670
671
}
671
- let email ;
672
- if ( ! invite . userId ) {
672
+
673
+ if ( invite . email ) {
673
674
// mask email if non-admin or not own invite
674
- email = isAdmin || invite . createdBy === currentUserId ? invite . email : util . maskEmail ( invite . email ) ;
675
- } else {
676
- // userId is defined, no email field returned
677
- email = null ;
678
- }
679
- _ . assign ( invite , { email } ) ;
680
- if ( ! invite . email && _ . has ( invite , 'hashEmail' ) ) {
681
- _ . assign ( invite , { hashEmail : null } ) ;
675
+ _ . assign ( invite , {
676
+ email : isAdmin || invite . createdBy === currentUserId ? invite . email : util . maskEmail ( invite . email ) ,
677
+ } ) ;
678
+
679
+ // for non-admin users don't return `userId` for invites created by `email`
680
+ if ( invite . userId && ! isAdmin ) {
681
+ _ . assign ( invite , {
682
+ userId : null ,
683
+ } ) ;
684
+ }
682
685
}
686
+
683
687
return invite ;
684
688
} ;
685
689
You can’t perform that action at this time.
0 commit comments