Skip to content

Commit 8e2dc03

Browse files
committed
account manager topcoder role
1 parent c8f2de9 commit 8e2dc03

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const PROJECT_MEMBER_MANAGER_ROLES = [PROJECT_MEMBER_ROLE.MANAGER, PROJEC
2626
export const USER_ROLE = {
2727
TOPCODER_ADMIN: 'administrator',
2828
MANAGER: 'Connect Manager',
29+
TOPCODER_ACCOUNT_MANAGER: 'Connect Account Manager',
2930
COPILOT: 'Connect Copilot',
3031
CONNECT_ADMIN: 'Connect Admin',
3132
};

src/permissions/project.view.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports = freq => new Promise((resolve, reject) => {
2222
// check if auth user has acecss to this project
2323
const hasAccess = util.hasAdminRole(req)
2424
|| util.hasRole(req, USER_ROLE.MANAGER)
25+
|| util.hasRole(req, USER_ROLE.ACCOUNT_MANAGER)
2526
|| !_.isUndefined(_.find(members, m => m.userId === currentUserId));
2627

2728
// if user is co-pilot and the project doesn't have any copilots then

src/routes/projectMembers/create.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,29 @@ module.exports = [
3232
if (_.get(req, 'body.param.role')) {
3333
targetRole = _.get(req, 'body.param.role');
3434

35-
if ([PROJECT_MEMBER_ROLE.MANAGER, PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER].includes(targetRole) &&
35+
if (PROJECT_MEMBER_ROLE.MANAGER === targetRole &&
3636
!util.hasRoles(req, [USER_ROLE.MANAGER])) {
3737
const err = new Error(`Only manager is able to join as ${targetRole}`);
3838
err.status = 401;
3939
return next(err);
4040
}
4141

42+
if (PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER === targetRole &&
43+
!util.hasRoles(req, [USER_ROLE.MANAGER, USER_ROLE.ACCOUNT_MANAGER])) {
44+
const err = new Error(`Only manager or account manager is able to join as ${targetRole}`);
45+
err.status = 401;
46+
return next(err);
47+
}
48+
4249
if (targetRole === PROJECT_MEMBER_ROLE.COPILOT && !util.hasRoles(req, [USER_ROLE.COPILOT])) {
4350
const err = new Error(`Only copilot is able to join as ${targetRole}`);
4451
err.status = 401;
4552
return next(err);
4653
}
4754
} else if (util.hasRoles(req, [USER_ROLE.MANAGER, USER_ROLE.CONNECT_ADMIN])) {
4855
targetRole = PROJECT_MEMBER_ROLE.MANAGER;
56+
} else if (util.hasRoles(req, [USER_ROLE.ACCOUNT_MANAGER])) {
57+
targetRole = PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER;
4958
} else if (util.hasRoles(req, [USER_ROLE.COPILOT, USER_ROLE.CONNECT_ADMIN])) {
5059
targetRole = PROJECT_MEMBER_ROLE.COPILOT;
5160
} else {

src/routes/projects/list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ module.exports = [
430430

431431
if (!memberOnly
432432
&& (util.hasAdminRole(req)
433-
|| util.hasRole(req, USER_ROLE.MANAGER))) {
433+
|| util.hasRole(req, USER_ROLE.MANAGER)
434+
|| util.hasRole(req, USER_ROLE.ACCOUNT_MANAGER))) {
434435
// admins & topcoder managers can see all projects
435436
return retrieveProjects(req, criteria, sort, req.query.fields)
436437
.then(result => res.json(util.wrapResponse(req.id, result.rows, result.count)))

0 commit comments

Comments
 (0)