-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored copilotAndAbove permission "middleware" to use general uti…
…l.hasPermission method to check permission instead of reimplementing logic
- Loading branch information
Showing
2 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Definitions of permissions which could be used with util methods | ||
* `util.hasPermission` or `util.hasPermissionForProject`. | ||
* | ||
* We can define permission using two logics: | ||
* 1. **WHAT** can be done with such a permission. Such constants may have names like: | ||
* - `VIEW_PROJECT` | ||
* - `EDIT_MILESTONE` | ||
* - `DELETE_WORK` | ||
* and os on. | ||
* 2. **WHO** can do actions with such a permission. Such constants **MUST** start from the prefix `ROLES_`, examples: | ||
* - `ROLES_COPILOT_AND_ABOVE` | ||
* - `ROLES_PROJECT_MEMBERS` | ||
* - `ROLES_ADMINS` | ||
*/ | ||
import { | ||
PROJECT_MEMBER_ROLE, | ||
ADMIN_ROLES, | ||
} from '../constants'; | ||
|
||
export const PERMISSION = { // eslint-disable-line import/prefer-default-export | ||
/** | ||
* Permissions defined by logic: **WHO** can do actions with such a permission. | ||
*/ | ||
ROLES_COPILOT_AND_ABOVE: { | ||
topcoderRoles: ADMIN_ROLES, | ||
projectRoles: [ | ||
PROJECT_MEMBER_ROLE.MANAGER, | ||
PROJECT_MEMBER_ROLE.COPILOT, | ||
], | ||
}, | ||
/** | ||
* Permissions defined by logic: **WHAT** can be done with such a permission. | ||
*/ | ||
}; | ||
|
This file contains 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