Handle falsy API values

This commit is contained in:
boatbomber 2023-01-05 11:28:37 -05:00
parent 9cf195691c
commit d83543e3cc

View file

@ -201,10 +201,10 @@ function API.new(app)
-- Sanitize request -- Sanitize request
local sanitizedApis = {} local sanitizedApis = {}
for _, api in apis do for _, api in apis do
if Rojo[api] then if Rojo[api] ~= nil then
table.insert(sanitizedApis, api) table.insert(sanitizedApis, api)
else else
warn(string.format("Rojo.%s is not a valid API", api)) warn(string.format("Rojo.%s is not a valid API", tostring(api)))
end end
end end
assert(#sanitizedApis > 0, "Rojo:RequestAccess expects an array of valid API names") assert(#sanitizedApis > 0, "Rojo:RequestAccess expects an array of valid API names")
@ -329,6 +329,12 @@ function API.new(app)
return nil return nil
end end
-- Existence check
if Rojo[key] == nil then
warn(string.format("Rojo.%s is not a valid API", tostring(key)))
return nil
end
-- Permissions check -- Permissions check
local granted = Rojo:_permissionCheck(key) local granted = Rojo:_permissionCheck(key)
if not granted then if not granted then