Changeset

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
parents 11897:e84ea5b58b29
children 11899:6d06068363aa
files core/usermanager.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
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