core.usermanager: Fire events when enabling and disabling users

Allow modules to act on this state change, e.g. kick accounts etc.
This commit is contained in:
Kim Alvefur 2023-02-23 16:25:31 +01:00
parent 931c14e50b
commit bb65a83696

View file

@ -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)