You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/permissions-guide/permissions-guide.md
+8-5
Original file line number
Diff line number
Diff line change
@@ -18,20 +18,23 @@ Let's say you would like to add a new place in code where you want to check user
18
18
19
19
2. After you add a new permission, regenerate [permissions list](https://htmlpreview.github.io/?https://github.com/appirio-tech/connect-app/blob/dev/docs/permissions.html) by running `npm run generate:doc:permissions`.
20
20
21
-
3. To check if user has permission in code use method `hasPermission(permission)`.
21
+
3. To check if logged-in user has permission in code use method `hasPermission(permission)`.
if (hasPermission(PERMISSIONS.MANAGE_PROJECT_PLAN)) {
30
30
...
31
31
}
32
32
```
33
33
34
-
- Note, optionally, you may pass the `project` object like this `hasPermission(permission, project)`. But you don't have to as `hasPermission` gets `project` object from the Redux Store (`projectState.project`) automatically. Only in case if you want to check user permission to another project which is not loaded into the Redux Store then you may pass `project` explicitly.
34
+
4. If you would like to check permissions for other user (not the current user) or for other project (not the current project) you may pass the second argument `entities: { project?: object, user?: object }`:
35
+
-`hasPermission(permission, { project })` - check permissions for another project
36
+
-`hasPermission(permission, { user })` - check permissions for another user
37
+
-`hasPermission(permission, { project, user })` - check permissions for another project and user
35
38
36
39
## Roles
37
40
@@ -49,4 +52,4 @@ By default every user has one role `Topcoder User`, generally this means that su
49
52
50
53
When user joins some project and become a member of the project, such a user has one **Project Role** inside that project. One user may have different **Project Role** in different projects. See [the list of all Project Roles](https://github.com/appirio-tech/connect-app/blob/dev/src/config/constants.js#L638-L647) which we use in Connect App.
<li><spanclass="badge badge-primary">allowed Project Role</span> - users with such a <strong>Project Role</strong> are allowed to perform the action</li>
24
-
<li><spanclass="badge badge-warning">denied Project Role</span> - users with such a <strong>Project Role</strong> are denied to perform the action even they have some other allow roles</li>
67
+
<li><spanclass="badge badge-primary badge-crossed">denied Project Role</span> - users with such a <strong>Project Role</strong> are denied to perform the action even they have some other allow roles</li>
25
68
<li><spanclass="badge badge-success">allowed Topcoder Role</span> - users with such a <strong>Topcoder Role</strong> are allowed to perform the action</li>
26
-
<li><spanclass="badge badge-danger">denied Topcoder Role</span> - users with such a <strong>Topcoder Role</strong> are denied to perform the action even they have some other allow roles</li>
69
+
<li><spanclass="badge badge-success badge-crossed">denied Topcoder Role</span> - users with such a <strong>Topcoder Role</strong> are denied to perform the action even they have some other allow roles</li>
0 commit comments