Diff

plugins/mod_auth_internal_plain.lua @ 12950:2cb5994e3f94

mod_auth_internal_plain: Fix user creation done via mod_admin_shell Following the new behavior in auth_internal_hashed (c8f59ce7d3cf), the account will be created and disabled, instead of returning an error telling password being nil when calling saslprep(). Note that mod_auth_internal_plain does not have full support for enabled/disabled accounts, but that may be fixed in subsequent commits.
author Vitaly Orekhov <vkvo2000@vivaldi.net>
date Tue, 21 Mar 2023 01:46:47 +0300
parent 12646:3f38f4735c7a
child 12977:74b9e05af71e
line wrap: on
line diff
--- a/plugins/mod_auth_internal_plain.lua	Fri Mar 17 15:11:26 2023 +0100
+++ b/plugins/mod_auth_internal_plain.lua	Tue Mar 21 01:46:47 2023 +0300
@@ -77,11 +77,14 @@
 end
 
 function provider.create_user(username, password)
+	local now = os.time();
+	if password == nil then
+		return accounts:set(username, { created = now, updated = now, disabled = true });
+	end
 	password = saslprep(password);
 	if not password then
 		return nil, "Password fails SASLprep.";
 	end
-	local now = os.time();
 	return accounts:set(username, {
 		password = password;
 		created = now, updated = now;