Require permission meta to be table or nil

master
rubenwardy 2018-11-23 03:04:33 +00:00
parent 5987b85bfb
commit 68c4f44470
3 changed files with 11 additions and 3 deletions

View File

@ -86,6 +86,7 @@ function company.check_perm(pname, cname, permission, meta)
assert(type(cname) == "string")
assert(type(permission) == "string")
assert(company.permissions[permission])
assert(meta == nil or type(meta) == "table")
local comp = company.get_active(pname)
if not comp then

View File

@ -52,8 +52,12 @@ function Company:can_become_active(username)
return self:check_perm(username, "SWITCH_TO")
end
function Company:check_perm(username, permission)
function Company:check_perm(username, permission, meta)
assert(type(username) == "string")
assert(type(permission) == "string")
assert(company.permissions[permission])
assert(meta == nil or type(meta) == "table")
-- TODO: permissions
return self:get_ownership(username) > 0
end

View File

@ -19,11 +19,14 @@ function areas:canInteract(pos, name)
-- end
for id, area in pairs(areas) do
area.id = id
local is_company = area.owner:sub(1, 2) == "c:"
if area.open then
return true
elseif is_company then
if company.check_perm(name, area.owner, "INTERACT_AREA", id) then
if company.check_perm(name, area.owner, "INTERACT_AREA",
{ area = area }) then
return true
end
elseif area.owner == name then
@ -41,7 +44,7 @@ function areas:isAreaOwner(id, name)
while cur do
local is_company = cur.owner:sub(1, 2) == "c:"
if is_company and
company.check_perm(name, cur.owner, "OWNS_AREA", id) then
company.check_perm(name, cur.owner, "OWNS_AREA", { area = cur }) then
return true
elseif cur.owner == name then
return true