reorganize logic

This commit is contained in:
Ben Irvin 2022-08-11 12:18:53 +02:00
parent 22c82a7258
commit e4d1f59b34

View File

@ -76,7 +76,12 @@ const verify = (auth, config) => {
}
// Custom
else if (apiToken.type === constants.API_TOKEN_TYPE.CUSTOM && ability) {
else if (apiToken.type === constants.API_TOKEN_TYPE.CUSTOM) {
if (!ability) {
console.log('missing ability');
throw new ForbiddenError();
}
const scopes = castArray(config.scope);
const isAllowed = scopes.every(scope => ability.can(scope));