From bb65a83696d7afb320bddbd38ef8480c0e3f5a6a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 23 Feb 2023 16:25:31 +0100 Subject: core.usermanager: Fire events when enabling and disabling users Allow modules to act on this state change, e.g. kick accounts etc. --- core/usermanager.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/usermanager.lua b/core/usermanager.lua index 439d4a8b..3afb5037 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -155,13 +155,21 @@ end local function enable_user(username, host) local method = hosts[host].users.enable; if not method then return nil, "method-not-supported"; end - return method(username); + local ret, err = method(username); + if ret then + prosody.events.fire_event("user-enabled", { username = username, host = host }); + end + return ret, err; end local function disable_user(username, host) local method = hosts[host].users.disable; if not method then return nil, "method-not-supported"; end - return method(username); + local ret, err = method(username); + if ret then + prosody.events.fire_event("user-disabled", { username = username, host = host }); + end + return ret, err; end local function users(host) -- cgit v1.2.3