mod_compat_roles: Fix attempt to index a nil value #1847
authorKim Alvefur <zash@zash.se>
Sat, 23 Mar 2024 15:44:13 +0100
changeset 5878 f8b9095f7862
parent 5877 a88c43de648c
child 5879 61bee1be6db3
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.
mod_compat_roles/mod_compat_roles.lua
--- 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)