mod_auth_internal_hashed: Allow creating disabled account without password
authorKim Alvefur <zash@zash.se>
Thu, 18 Aug 2022 17:50:56 +0200
changeset 12673 aed38948791f
parent 12672 5d85de8b0723
child 12674 4a00c8811ea8
mod_auth_internal_hashed: Allow creating disabled account without password Otherwise, create_user(username, nil) leads to the account being deleted.
plugins/mod_auth_internal_hashed.lua
--- a/plugins/mod_auth_internal_hashed.lua	Thu Aug 18 16:46:07 2022 +0100
+++ b/plugins/mod_auth_internal_hashed.lua	Thu Aug 18 17:50:56 2022 +0200
@@ -115,8 +115,9 @@
 end
 
 function provider.create_user(username, password)
+	local now = os.time();
 	if password == nil then
-		return accounts:set(username, {});
+		return accounts:set(username, { created = now; updated = now; disabled = true });
 	end
 	local salt = generate_uuid();
 	local valid, stored_key, server_key = get_auth_db(password, salt, default_iteration_count);
@@ -125,7 +126,6 @@
 	end
 	local stored_key_hex = to_hex(stored_key);
 	local server_key_hex = to_hex(server_key);
-	local now = os.time();
 	return accounts:set(username, {
 		stored_key = stored_key_hex, server_key = server_key_hex,
 		salt = salt, iteration_count = default_iteration_count,