Comparison

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
comparison
equal deleted inserted replaced
12949:2f61ebcf37c0 12950:2cb5994e3f94
75 function provider.users() 75 function provider.users()
76 return accounts:users(); 76 return accounts:users();
77 end 77 end
78 78
79 function provider.create_user(username, password) 79 function provider.create_user(username, password)
80 local now = os.time();
81 if password == nil then
82 return accounts:set(username, { created = now, updated = now, disabled = true });
83 end
80 password = saslprep(password); 84 password = saslprep(password);
81 if not password then 85 if not password then
82 return nil, "Password fails SASLprep."; 86 return nil, "Password fails SASLprep.";
83 end 87 end
84 local now = os.time();
85 return accounts:set(username, { 88 return accounts:set(username, {
86 password = password; 89 password = password;
87 created = now, updated = now; 90 created = now, updated = now;
88 }); 91 });
89 end 92 end