usermanager, mod_auth_internal_hashed: Support metadata when disabling a user

This allows us to store a time, actor, comment and/or reason why an account
was disabled, which seems a generally useful thing to support.
This commit is contained in:
Matthew Wild 2023-11-30 09:47:00 +00:00
parent b97c4ffc16
commit 253b2fba90
2 changed files with 5 additions and 4 deletions

View file

@ -163,12 +163,12 @@ local function enable_user(username, host)
return ret, err;
end
local function disable_user(username, host)
local function disable_user(username, host, meta)
local method = hosts[host].users.disable;
if not method then return nil, "method not supported"; end
local ret, err = method(username);
local ret, err = method(username, meta);
if ret then
prosody.events.fire_event("user-disabled", { username = username, host = host });
prosody.events.fire_event("user-disabled", { username = username, host = host, meta = meta });
end
return ret, err;
end

View file

@ -126,9 +126,10 @@ function provider.enable(username)
return accounts:set(username, account);
end
function provider.disable(username)
function provider.disable(username, meta)
local account = accounts:get(username);
account.disabled = true;
account.disabled_meta = meta;
account.updated = os.time();
return accounts:set(username, account);
end