# HG changeset patch # User Kim Alvefur # Date 1677165931 -3600 # Node ID e282c92ded0efd8bbfc3922c8c940fea32bdea6d # Parent 8473a516004f7af8a38075a9c42eb89c7b75b0ed core.usermanager: Fire events when enabling and disabling users Allow modules to act on this state change, e.g. kick accounts etc. diff -r 8473a516004f -r e282c92ded0e core/usermanager.lua --- a/core/usermanager.lua Thu Feb 23 16:24:41 2023 +0100 +++ b/core/usermanager.lua Thu Feb 23 16:25:31 2023 +0100 @@ -155,13 +155,21 @@ 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)