Comparison

core/moduleapi.lua @ 12650:e08bf2ad67da

moduleapi: Distribute permissions set from global modules to all hosts Roles and permissions will always happen in the context of a host. Prevents error upon indexing since `hosts["*"] == nil`
author Kim Alvefur <zash@zash.se>
date Wed, 20 Jul 2022 13:05:35 +0200
parent 12645:a741183eec97
child 12651:1ce98f27eabe
comparison
equal deleted inserted replaced
12649:86e1187f6274 12650:e08bf2ad67da
602 return self.status_type, self.status_message, self.status_time; 602 return self.status_type, self.status_message, self.status_time;
603 end 603 end
604 604
605 function api:default_permission(role_name, permission) 605 function api:default_permission(role_name, permission)
606 permission = permission:gsub("^:", self.name..":"); 606 permission = permission:gsub("^:", self.name..":");
607 if self.host == "*" then
608 for _, host in pairs(hosts) do
609 if host.authz then
610 host.authz.add_default_permission(role_name, permission);
611 end
612 end
613 return
614 end
607 hosts[self.host].authz.add_default_permission(role_name, permission); 615 hosts[self.host].authz.add_default_permission(role_name, permission);
608 end 616 end
609 617
610 function api:default_permissions(role_name, permissions) 618 function api:default_permissions(role_name, permissions)
611 for _, permission in ipairs(permissions) do 619 for _, permission in ipairs(permissions) do