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.
--- a/mod_compat_roles/mod_compat_roles.lua Fri Mar 22 11:02:04 2024 +0100
+++ b/mod_compat_roles/mod_compat_roles.lua Sat Mar 23 15:44:13 2024 +0100
@@ -50,8 +50,14 @@
if not role_permissions then
return false;
end
+ if role_permissions[permission] then
+ return true;
+ end
local next_role = role_inheritance[role_name];
- return not not permissions[role_name][permission] or (next_role and role_may(host, next_role, permission));
+ if not next_role then
+ return false;
+ end
+ return role_may(host, next_role, permission);
end
function moduleapi.may(self, action, context)