# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1660839044 -7200
# Node ID 32881d0c359fe4039d222890f7362409d67e2181
# Parent  4a00c8811ea8d805a2e1d2b2658dbecbbd2c6448
mod_auth_insecure: Store creation and update timestamps on account

This ensures that the store is not empty in case no password is
provided, so the underlying data storage won't consider the store empty.

diff -r 4a00c8811ea8 -r 32881d0c359f plugins/mod_auth_insecure.lua
--- a/plugins/mod_auth_insecure.lua	Thu Aug 18 18:10:18 2022 +0200
+++ b/plugins/mod_auth_insecure.lua	Thu Aug 18 18:10:44 2022 +0200
@@ -27,6 +27,7 @@
 		return nil, "Password fails SASLprep.";
 	end
 	if account then
+		account.updated = os.time();
 		account.password = password;
 		return datamanager.store(username, host, "accounts", account);
 	end
@@ -38,7 +39,8 @@
 end
 
 function provider.create_user(username, password)
-	return datamanager.store(username, host, "accounts", {password = password});
+	local now = os.time();
+	return datamanager.store(username, host, "accounts", { created = now; updated = now; password = password });
 end
 
 function provider.delete_user(username)