Software /
code /
prosody
Diff
plugins/mod_auth_internal_plain.lua @ 12646:3f38f4735c7a
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).
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 12 Jul 2022 13:14:47 +0100 |
parent | 11544:c98aebe601f9 |
child | 12950:2cb5994e3f94 |
line wrap: on
line diff
--- a/plugins/mod_auth_internal_plain.lua Wed Jun 15 23:04:17 2022 +0200 +++ b/plugins/mod_auth_internal_plain.lua Tue Jul 12 13:14:47 2022 +0100 @@ -48,11 +48,21 @@ 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 @@ 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)