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
local sanitizedApis = {}
for _, api in apis do
if Rojo[api] then
if Rojo[api] ~= nil then
table.insert(sanitizedApis, api)
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
assert(#sanitizedApis > 0, "Rojo:RequestAccess expects an array of valid API names")
@ -329,6 +329,12 @@ function API.new(app)
return nil
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
local granted = Rojo:_permissionCheck(key)
if not granted then