MCPcopy Index your code
hub / github.com/chartbrew/chartbrew / checkAccess

Function checkAccess

server/api/IntegrationRoute.js:9–26  ·  view source on GitHub ↗
(team_id, integration_id, user, teamAccess, integrationAccess)

Source from the content-addressed store, hash-verified

7 const teamController = new TeamController();
8
9 const checkAccess = (team_id, integration_id, user, teamAccess, integrationAccess) => {
10 return teamController.getTeamRole(team_id, user.id)
11 .then((teamRole) => {
12 const permission = accessControl.can(teamRole.role)[teamAccess]("team");
13 if (!permission.granted) {
14 return new Promise((resolve, reject) => reject(new Error(401)));
15 }
16
17 if (integration_id) {
18 const integrationPermission = accessControl.can(teamRole.role)[integrationAccess]("integration");
19 if (!integrationPermission.granted) {
20 return new Promise((resolve, reject) => reject(new Error(401)));
21 }
22 }
23
24 return teamRole;
25 });
26 };
27 // ----------------------------------------------
28
29 /*

Callers 1

Calls 1

getTeamRoleMethod · 0.80

Tested by

no test coverage detected