Make permissionTest() throw an error on fail. Having to remember to check the value scares me too much.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3960 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-08-14 17:34:27 +00:00
parent 4525ee9cca
commit 8edc9aaa63

View File

@ -215,7 +215,7 @@ async function getProcessBlob(blobId, key, options) {
if (gGlobalSettings.userPermissions[user][options.packageOwner][options.packageName][permission]) { if (gGlobalSettings.userPermissions[user][options.packageOwner][options.packageName][permission]) {
return true; return true;
} else { } else {
return false; throw Error(`Permission denied: ${permission}.`);
} }
} else { } else {
@ -227,13 +227,11 @@ async function getProcessBlob(blobId, key, options) {
return true; return true;
} else if (value == 'deny') { } else if (value == 'deny') {
storePermission(user, options.packageOwner, options.packageName, permission, false); storePermission(user, options.packageOwner, options.packageName, permission, false);
return false; throw Error(`Permission denied: ${permission}.`);
} else if (value == 'deny once') { } else if (value == 'deny once') {
return false; throw Error(`Permission denied: ${permission}.`);
} }
return false; throw Error(`Permission denied: ${permission}.`);
}).catch(function() {
return false;
}); });
} }
}, },
@ -296,10 +294,8 @@ async function getProcessBlob(blobId, key, options) {
if (process.credentials && if (process.credentials &&
process.credentials.session && process.credentials.session &&
process.credentials.session.name) { process.credentials.session.name) {
return imports.core.permissionTest('ssb_append').then(function(value) { return imports.core.permissionTest('ssb_append').then(function() {
if (value) { return ssb.appendMessageWithIdentity(process.credentials.session.name, id, message);
return ssb.appendMessageWithIdentity(process.credentials.session.name, id, message);
}
}); });
} }
}; };