Comparison

plugins/mod_auth_internal_hashed.lua @ 12902:0a0a251bcd6c

mod_auth_internal_hashed: Implement is_enabled() method Uses 'disabled' property already introduced in aed38948791f
author Kim Alvefur <zash@zash.se>
date Thu, 23 Feb 2023 14:34:10 +0100
parent 12901:b884ddb5a0e7
child 12903:13950bf92802
comparison
equal deleted inserted replaced
12901:b884ddb5a0e7 12902:0a0a251bcd6c
96 local account = accounts:get(username); 96 local account = accounts:get(username);
97 if not account then return nil, "Account not available"; end 97 if not account then return nil, "Account not available"; end
98 return { 98 return {
99 created = account.created; 99 created = account.created;
100 password_updated = account.updated; 100 password_updated = account.updated;
101 enabled = not account.disabled;
101 }; 102 };
102 end 103 end
103 104
104 function provider.user_exists(username) 105 function provider.user_exists(username)
105 local account = accounts:get(username); 106 local account = accounts:get(username);
109 end 110 end
110 return true; 111 return true;
111 end 112 end
112 113
113 function provider.is_enabled(username) -- luacheck: ignore 212 114 function provider.is_enabled(username) -- luacheck: ignore 212
114 -- TODO look up somewhere and allow disabling 115 local info, err = provider.get_account_info(username);
115 return true; 116 if not info then return nil, err; end
117 return info.enabled;
116 end 118 end
117 119
118 function provider.enable(username) -- luacheck: ignore 212 120 function provider.enable(username) -- luacheck: ignore 212
119 error "NYI" 121 error "NYI"
120 end 122 end
168 170
169 local stored_key, server_key = credentials.stored_key, credentials.server_key; 171 local stored_key, server_key = credentials.stored_key, credentials.server_key;
170 local iteration_count, salt = credentials.iteration_count, credentials.salt; 172 local iteration_count, salt = credentials.iteration_count, credentials.salt;
171 stored_key = stored_key and from_hex(stored_key); 173 stored_key = stored_key and from_hex(stored_key);
172 server_key = server_key and from_hex(server_key); 174 server_key = server_key and from_hex(server_key);
173 return stored_key, server_key, iteration_count, salt, provider.is_enabled(username); 175 return stored_key, server_key, iteration_count, salt, not credentials.disabled;
174 end 176 end
175 }; 177 };
176 return new_sasl(host, testpass_authentication_profile); 178 return new_sasl(host, testpass_authentication_profile);
177 end 179 end
178 180