changeset 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 (9 months ago)
parents a88c43de648c
children 61bee1be6db3
files mod_compat_roles/mod_compat_roles.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)