diff --git a/lib/utils.js b/lib/utils.js index 59437da..788bb4c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -28,7 +28,7 @@ module.exports = class AccessUtils { // Validate the format of options.groupRoles ($group:[role]). this.options.groupRoles.forEach(name => { - if (!AccessUtils.isValidPrincipalId(name)) { + if (!this.isValidPrincipalId(name)) { throw new Error('$name is an invalid access group name.') } }) @@ -253,7 +253,7 @@ module.exports = class AccessUtils { * @param {String} principalId A principalId. * @returns {Boolean} Returns true if the principalId is on the expected format. */ - static isValidPrincipalId(principalId) { + isValidPrincipalId(principalId) { return Boolean(this.extractRoleName(principalId)) } @@ -263,7 +263,7 @@ module.exports = class AccessUtils { * @param {String} principalId A principalId. * @returns {Boolean} Returns true if the principalId is on the expected format. */ - static extractRoleName(principalId) { + extractRoleName(principalId) { return principalId.split(':')[1] } @@ -281,7 +281,7 @@ module.exports = class AccessUtils { const modelClass = context.model const { modelId } = context const userId = context.getUserId() - const roleName = AccessUtils.extractRoleName(role) + const roleName = this.extractRoleName(role) const GroupAccess = this.app.models[this.options.groupAccessModel] const scope = { }