-
Notifications
You must be signed in to change notification settings - Fork 56
implement new roles #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vikasrohit
merged 2 commits into
topcoder-platform:feature/new-roles
from
unknown repository
Sep 26, 2019
Merged
implement new roles #383
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,15 @@ const createProjectMemberValidations = { | |
param: Joi.object() | ||
.keys({ | ||
role: Joi.any() | ||
.valid(PROJECT_MEMBER_ROLE.MANAGER, PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER, PROJECT_MEMBER_ROLE.COPILOT), | ||
.valid( | ||
PROJECT_MEMBER_ROLE.MANAGER, | ||
PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER, | ||
PROJECT_MEMBER_ROLE.COPILOT, | ||
PROJECT_MEMBER_ROLE.PROJECT_MANAGER, | ||
PROJECT_MEMBER_ROLE.PROGRAM_MANAGER, | ||
PROJECT_MEMBER_ROLE.SOLUTION_ARCHITECT, | ||
PROJECT_MEMBER_ROLE.ACCOUNT_EXECUTIVE, | ||
), | ||
}), | ||
}, | ||
}; | ||
|
@@ -39,9 +47,45 @@ module.exports = [ | |
return next(err); | ||
} | ||
|
||
if (PROJECT_MEMBER_ROLE.SOLUTION_ARCHITECT === targetRole && | ||
!util.hasRoles(req, [USER_ROLE.SOLUTION_ARCHITECT])) { | ||
const err = new Error(`Only solution architect is able to join as ${targetRole}`); | ||
err.status = 401; | ||
return next(err); | ||
} | ||
|
||
if (PROJECT_MEMBER_ROLE.PROJECT_MANAGER === targetRole && | ||
!util.hasRoles(req, [USER_ROLE.PROJECT_MANAGER])) { | ||
const err = new Error(`Only project manager is able to join as ${targetRole}`); | ||
err.status = 401; | ||
return next(err); | ||
} | ||
|
||
if (PROJECT_MEMBER_ROLE.PROGRAM_MANAGER === targetRole && | ||
!util.hasRoles(req, [USER_ROLE.PROGRAM_MANAGER])) { | ||
const err = new Error(`Only program manager is able to join as ${targetRole}`); | ||
err.status = 401; | ||
return next(err); | ||
} | ||
|
||
if (PROJECT_MEMBER_ROLE.ACCOUNT_EXECUTIVE === targetRole && | ||
!util.hasRoles(req, [USER_ROLE.ACCOUNT_EXECUTIVE])) { | ||
const err = new Error(`Only account executive is able to join as ${targetRole}`); | ||
err.status = 401; | ||
return next(err); | ||
} | ||
|
||
if (PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER === targetRole && | ||
!util.hasRoles(req, [USER_ROLE.MANAGER, USER_ROLE.TOPCODER_ACCOUNT_MANAGER])) { | ||
const err = new Error(`Only manager or account manager is able to join as ${targetRole}`); | ||
!util.hasRoles(req, [ | ||
USER_ROLE.MANAGER, | ||
USER_ROLE.TOPCODER_ACCOUNT_MANAGER, | ||
USER_ROLE.BUSINESS_DEVELOPMENT_REPRESENTATIVE, | ||
USER_ROLE.PRESALES, | ||
])) { | ||
const err = new Error( | ||
`Only manager, account manager, business development representative, | ||
or presales are able to join as ${targetRole}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fikzzzy if we add more roles above, we also have to update this message. |
||
); | ||
err.status = 401; | ||
return next(err); | ||
} | ||
|
@@ -53,10 +97,22 @@ module.exports = [ | |
} | ||
} else if (util.hasRoles(req, [USER_ROLE.MANAGER, USER_ROLE.CONNECT_ADMIN])) { | ||
maxceem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
targetRole = PROJECT_MEMBER_ROLE.MANAGER; | ||
} else if (util.hasRoles(req, [USER_ROLE.TOPCODER_ACCOUNT_MANAGER])) { | ||
} else if (util.hasRoles(req, [ | ||
USER_ROLE.TOPCODER_ACCOUNT_MANAGER, | ||
USER_ROLE.BUSINESS_DEVELOPMENT_REPRESENTATIVE, | ||
USER_ROLE.PRESALES, | ||
maxceem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
])) { | ||
targetRole = PROJECT_MEMBER_ROLE.ACCOUNT_MANAGER; | ||
} else if (util.hasRoles(req, [USER_ROLE.COPILOT, USER_ROLE.CONNECT_ADMIN])) { | ||
targetRole = PROJECT_MEMBER_ROLE.COPILOT; | ||
} else if (util.hasRoles(req, [USER_ROLE.ACCOUNT_EXECUTIVE])) { | ||
targetRole = PROJECT_MEMBER_ROLE.ACCOUNT_EXECUTIVE; | ||
} else if (util.hasRoles(req, [USER_ROLE.PROGRAM_MANAGER])) { | ||
targetRole = PROJECT_MEMBER_ROLE.PROGRAM_MANAGER; | ||
} else if (util.hasRoles(req, [USER_ROLE.SOLUTION_ARCHITECT])) { | ||
targetRole = PROJECT_MEMBER_ROLE.SOLUTION_ARCHITECT; | ||
} else if (util.hasRoles(req, [USER_ROLE.PROJECT_MANAGER])) { | ||
targetRole = PROJECT_MEMBER_ROLE.PROJECT_MANAGER; | ||
} else { | ||
const err = new Error('Only copilot or manager is able to call this endpoint'); | ||
err.status = 401; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fikzzzy it looks like we have to add to this list all new USER_ROLES. As before we had there both
USER_ROLE.MANAGER
andUSER_ROLE.TOPCODER_ACCOUNT_MANAGER
.