Skip to content

Commit a38763e

Browse files
Merge pull request #144 from terminusdb/update_access
Update access
2 parents 2141867 + d0561dc commit a38763e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/accessControl.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const UTILS = require('./utils');
3838

3939
function AccessControl(cloudAPIUrl, params) {
4040
this.baseURL = this.getAPIUrl(cloudAPIUrl);
41+
if(!params) return
4142
if (params.jwt) {
4243
this.setJwtToken(params.jwt);
4344
} else if (params.token) {
@@ -152,7 +153,7 @@ AccessControl.prototype.createOrganization = function (orgName) {
152153
);
153154
}
154155

155-
return this.dispatch(`${this.baseURL}/organizations`, CONST.POST, {
156+
return this.dispatch(`${this.baseURL}/private/organizations`, CONST.POST, {
156157
organization: orgName,
157158
});
158159
};
@@ -176,7 +177,7 @@ AccessControl.prototype.ifOrganizationExists = function (orgName) {
176177
);
177178
}
178179

179-
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(orgName)}`, CONST.HEAD);
180+
return this.dispatch(`${this.baseURL}/private/organizations/${UTILS.encodeURISegment(orgName)}`, CONST.HEAD);
180181
};
181182

182183
/**
@@ -402,6 +403,21 @@ AccessControl.prototype.getOrgUsers = function (orgName) {
402403
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/users`, CONST.GET);
403404
};
404405

406+
AccessControl.prototype.getTeamUserRole = function (orgName) {
407+
if (!orgName && !this.defaultOrganization) {
408+
return Promise.reject(
409+
new Error(
410+
ErrorMessage.getInvalidParameterMessage(
411+
'GET',
412+
'Please provide a organization name',
413+
),
414+
),
415+
);
416+
}
417+
const org = orgName || this.defaultOrganization;
418+
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/role`, CONST.GET);
419+
};
420+
405421
/**
406422
* Remove an user from an organization, only an admin user can remove an user from an organization
407423
* @param {string} userId - The id of the user to be removed. (this is the document user's @id)

0 commit comments

Comments
 (0)