Diff

core/usermanager.lua @ 11898:89aa591bb895

usermanager: Fire user-roles-changed event when updating roles of a local user
author Matthew Wild <mwild1@gmail.com>
date Fri, 12 Nov 2021 13:25:09 +0000
parent 11745:3a2d58a39872
child 12020:a949f1aae171
line wrap: on
line diff
--- a/core/usermanager.lua	Fri Nov 12 14:22:21 2021 +0100
+++ b/core/usermanager.lua	Fri Nov 12 13:25:09 2021 +0000
@@ -174,7 +174,13 @@
 
 	local authz_provider = (host ~= "*" and hosts[host].authz) or global_authz_provider;
 	if actor_user and actor_host == host then -- Local user
-		return authz_provider.set_user_roles(actor_user, roles)
+		local ok, err = authz_provider.set_user_roles(actor_user, roles);
+		if ok then
+			prosody.events.fire_event("user-roles-changed", {
+				username = actor_user, host = actor_host
+			});
+		end
+		return ok, err;
 	else -- Remote entity
 		return authz_provider.set_jid_roles(jid, roles)
 	end