File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
src/routes/projectReports Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,13 @@ LookApi.prototype.findProjectRegSubmissions = function (directProjectId) {
3838 return this . runQueryWithFilter ( queryId , view , fields , filters ) ;
3939} ;
4040
41- LookApi . prototype . findProjectBudget = function ( connectProjectId , isManager ) {
41+ LookApi . prototype . findProjectBudget = function ( connectProjectId , isManager , isAdmin ) {
4242 const queryId = config . lookerConfig . QUERIES . BUDGET ;
4343
4444 const fields = [ 'project_stream.total_invoiced_amount' , 'project_stream.remaining_invoiced_budget' ] ;
4545
4646 // Manager roles have access to more fields.
47- if ( isManager ) {
47+ if ( isManager || isAdmin ) {
4848 fields . push ( 'project_stream.total_actual_challenge_fee' , 'project_stream.total_actual_member_payment' ) ;
4949 }
5050 const view = 'project_stream' ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import models from '../../models';
77import LookApi from './LookRun' ;
88import mock from './mock' ;
99import util from '../../util' ;
10- import { PROJECT_MEMBER_MANAGER_ROLES } from '../../constants' ;
10+ import { PROJECT_MEMBER_MANAGER_ROLES , USER_ROLE } from '../../constants' ;
1111
1212const permissions = tcMiddleware . permissions ;
1313
@@ -37,15 +37,18 @@ module.exports = [
3737
3838 try {
3939 // check if auth user has acecss to this project
40- const isManager = util . hasRoles ( req , PROJECT_MEMBER_MANAGER_ROLES ) ;
40+ const members = req . context . currentProjectMembers ;
41+ const member = _ . find ( members , m => m . userId === req . authUser . userId ) ;
42+ const isManager = member && PROJECT_MEMBER_MANAGER_ROLES . indexOf ( member . role ) > - 1 ;
43+ const isAdmin = util . hasRoles ( req , [ USER_ROLE . CONNECT_ADMIN , USER_ROLE . TOPCODER_ADMIN ] ) ;
4144 // pick the report based on its name
4245 let result = { } ;
4346 switch ( reportName ) {
4447 case 'summary' :
4548 result = await lookApi . findProjectRegSubmissions ( directProjectId ) ;
4649 break ;
4750 case 'projectBudget' :
48- result = await lookApi . findProjectBudget ( projectId , isManager ) ;
51+ result = await lookApi . findProjectBudget ( projectId , isManager , isAdmin ) ;
4952 break ;
5053 default :
5154 return res . status ( 404 ) . send ( 'Report not found' ) ;
You can’t perform that action at this time.
0 commit comments