MCPcopy
hub / github.com/chartbrew/chartbrew / canAccess

Function canAccess

client/src/config/canAccess.js:4–36  ·  view source on GitHub ↗
(role, userId, teamRoles)

Source from the content-addressed store, hash-verified

2** this is used to improve the UX. The real role check is done in the backend
3*/
4export default function canAccess(role, userId, teamRoles) {
5 let teamRole = "guest";
6 if (teamRoles) {
7 for (let i = 0; i < teamRoles.length; i++) {
8 if (teamRoles[i].user_id === userId) {
9 teamRole = teamRoles[i].role;
10 break;
11 }
12 }
13 }
14
15 switch (role) {
16 case "teamOwner":
17 if (teamRole === "teamOwner") return true;
18 break;
19 case "teamAdmin":
20 if (teamRole === "teamOwner" || teamRole === "teamAdmin") return true;
21 break;
22 case "projectAdmin":
23 if (teamRole === "teamOwner" || teamRole === "teamAdmin" || teamRole === "projectAdmin") return true;
24 break;
25 case "projectEditor":
26 if (teamRole === "teamOwner" || teamRole === "teamAdmin" || teamRole === "projectAdmin" || teamRole === "projectEditor") return true;
27 break;
28 case "projectViewer":
29 if (teamRole === "teamOwner" || teamRole === "teamAdmin" || teamRole === "projectAdmin" || teamRole === "projectEditor" || teamRole === "projectViewer") return true;
30 break;
31 default:
32 return false;
33 }
34
35 return false;
36}

Callers 15

canUserAccessFunction · 0.85
_canAccessFunction · 0.85
_canAccessFunction · 0.85
MainFunction · 0.85
_canAccessFunction · 0.85
_canAccessFunction · 0.85
_canAccessFunction · 0.85
ChartDatasetsFunction · 0.85
ChartDescriptionFunction · 0.85
_canAccessFunction · 0.85
ChartDatasetConfigFunction · 0.85
_canAccessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected