util/roles.lua
changeset 12752 7b9de8109a90
parent 12750 7eabf8d78978
child 12979 d10957394a3c
--- a/util/roles.lua	Fri Oct 07 16:58:52 2022 +0100
+++ b/util/roles.lua	Fri Oct 07 17:01:35 2022 +0100
@@ -86,6 +86,16 @@
 	return true;
 end
 
+function role_methods:policies()
+	local policy_iterator, s, v = it.join(pairs(self[permissions_key]));
+	if self.inherits then
+		for _, inherited_role in ipairs(self.inherits) do
+			policy_iterator:append(inherited_role:policies());
+		end
+	end
+	return policy_iterator, s, v;
+end
+
 function role_mt.__tostring(self)
 	return ("role<[%s] %s>"):format(self.id or "nil", self.name or "[no name]");
 end