feat: gracefully handle missing objects

This commit is contained in:
Julien Fontanet 2016-04-27 15:52:13 +02:00
parent c921ea6eb7
commit 649ab26da8

View File

@ -89,6 +89,10 @@ const checkAuthorizationByTypes = {
// Hoisting is important for this function.
function checkAuthorization (objectId, permission) {
const object = getObject(objectId)
if (!object) {
return false
}
const checker = checkAuthorizationByTypes[object.type] || checkSelf
return checker(object, permission)