Comparison

plugins/mod_auth_insecure.lua @ 12671:32881d0c359f

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.
author Kim Alvefur <zash@zash.se>
date Thu, 18 Aug 2022 18:10:44 +0200
parent 10914:0d7d71dee0a0
child 12977:74b9e05af71e
comparison
equal deleted inserted replaced
12670:4a00c8811ea8 12671:32881d0c359f
25 password = saslprep(password); 25 password = saslprep(password);
26 if not password then 26 if not password then
27 return nil, "Password fails SASLprep."; 27 return nil, "Password fails SASLprep.";
28 end 28 end
29 if account then 29 if account then
30 account.updated = os.time();
30 account.password = password; 31 account.password = password;
31 return datamanager.store(username, host, "accounts", account); 32 return datamanager.store(username, host, "accounts", account);
32 end 33 end
33 return nil, "Account not available."; 34 return nil, "Account not available.";
34 end 35 end
36 function provider.user_exists(username) 37 function provider.user_exists(username)
37 return true; 38 return true;
38 end 39 end
39 40
40 function provider.create_user(username, password) 41 function provider.create_user(username, password)
41 return datamanager.store(username, host, "accounts", {password = password}); 42 local now = os.time();
43 return datamanager.store(username, host, "accounts", { created = now; updated = now; password = password });
42 end 44 end
43 45
44 function provider.delete_user(username) 46 function provider.delete_user(username)
45 return datamanager.store(username, host, "accounts", nil); 47 return datamanager.store(username, host, "accounts", nil);
46 end 48 end