From 4db3d1572390ce5b615282cb1112358d9e3ba892 Mon Sep 17 00:00:00 2001
From: Matthew Wild <mwild1@gmail.com>
Date: Tue, 12 Jul 2022 13:14:47 +0100
Subject: 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).
---
 core/usermanager.lua | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'core')

diff --git a/core/usermanager.lua b/core/usermanager.lua
index 970140ef..23571fe7 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -116,6 +116,12 @@ local function set_password(username, password, host, resource)
 	return ok, err;
 end
 
+local function get_account_info(username, host)
+	local method = hosts[host].users.get_account_info;
+	if not method then return nil, "method-not-supported"; end
+	return method(username);
+end
+
 local function user_exists(username, host)
 	if hosts[host].sessions[username] then return true; end
 	return hosts[host].users.user_exists(username);
@@ -211,6 +217,7 @@ return {
 	test_password = test_password;
 	get_password = get_password;
 	set_password = set_password;
+	get_account_info = get_account_info;
 	user_exists = user_exists;
 	create_user = create_user;
 	delete_user = delete_user;
-- 
cgit v1.2.3