aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_auth_internal_plain.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-07-12 13:14:47 +0100
committerMatthew Wild <mwild1@gmail.com>2022-07-12 13:14:47 +0100
commit4db3d1572390ce5b615282cb1112358d9e3ba892 (patch)
tree37bb45722201e08eb3e8a4ff1c88d27fbdd372ac /plugins/mod_auth_internal_plain.lua
parentaf339f0e66480da6825fd655a5bf35e2824cfc00 (diff)
downloadprosody-4db3d1572390ce5b615282cb1112358d9e3ba892.tar.gz
prosody-4db3d1572390ce5b615282cb1112358d9e3ba892.zip
usermanager, mod_auth_*: Add get_account_info() returning creation/update time
This is useful for a number of things. For example, listing users that need to rotate their passwords after some event. It also provides a safer way for code to determine that a user password has changed without needing to set a handler for the password change event (which is a more fragile approach).
Diffstat (limited to 'plugins/mod_auth_internal_plain.lua')
-rw-r--r--plugins/mod_auth_internal_plain.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/plugins/mod_auth_internal_plain.lua b/plugins/mod_auth_internal_plain.lua
index 8a50e820..0f65323c 100644
--- a/plugins/mod_auth_internal_plain.lua
+++ b/plugins/mod_auth_internal_plain.lua
@@ -48,11 +48,21 @@ function provider.set_password(username, password)
local account = accounts:get(username);
if account then
account.password = password;
+ account.updated = os.time();
return accounts:set(username, account);
end
return nil, "Account not available.";
end
+function provider.get_account_info(username)
+ local account = accounts:get(username);
+ if not account then return nil, "Account not available"; end
+ return {
+ created = account.created;
+ password_updated = account.updated;
+ };
+end
+
function provider.user_exists(username)
local account = accounts:get(username);
if not account then
@@ -71,7 +81,11 @@ function provider.create_user(username, password)
if not password then
return nil, "Password fails SASLprep.";
end
- return accounts:set(username, {password = password});
+ local now = os.time();
+ return accounts:set(username, {
+ password = password;
+ created = now, updated = now;
+ });
end
function provider.delete_user(username)