comparison mod_compat_roles/mod_compat_roles.lua @ 5874:f8b9095f7862

mod_compat_roles: Fix attempt to index a nil value #1847 permissions[] is not a map with role names as keys since 817bc9873fc2 but instead a level with host names were added. This was likely an oversight. Refactored towards railroad.
author Kim Alvefur <zash@zash.se>
date Sat, 23 Mar 2024 15:44:13 +0100
parents 825c6fb76c48
children
comparison
equal deleted inserted replaced
5873:a88c43de648c 5874:f8b9095f7862
48 end 48 end
49 local role_permissions = host_roles[role_name]; 49 local role_permissions = host_roles[role_name];
50 if not role_permissions then 50 if not role_permissions then
51 return false; 51 return false;
52 end 52 end
53 if role_permissions[permission] then
54 return true;
55 end
53 local next_role = role_inheritance[role_name]; 56 local next_role = role_inheritance[role_name];
54 return not not permissions[role_name][permission] or (next_role and role_may(host, next_role, permission)); 57 if not next_role then
58 return false;
59 end
60 return role_may(host, next_role, permission);
55 end 61 end
56 62
57 function moduleapi.may(self, action, context) 63 function moduleapi.may(self, action, context)
58 if action:byte(1) == 58 then -- action begins with ':' 64 if action:byte(1) == 58 then -- action begins with ':'
59 action = self.name..action; -- prepend module name 65 action = self.name..action; -- prepend module name