Software /
code /
prosody
Comparison
plugins/mod_auth_internal_hashed.lua @ 12669:aed38948791f
mod_auth_internal_hashed: Allow creating disabled account without password
Otherwise, create_user(username, nil) leads to the account being
deleted.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Aug 2022 17:50:56 +0200 |
parent | 12646:3f38f4735c7a |
child | 12900:5484debdfdfe |
comparison
equal
deleted
inserted
replaced
12668:5d85de8b0723 | 12669:aed38948791f |
---|---|
113 function provider.users() | 113 function provider.users() |
114 return accounts:users(); | 114 return accounts:users(); |
115 end | 115 end |
116 | 116 |
117 function provider.create_user(username, password) | 117 function provider.create_user(username, password) |
118 local now = os.time(); | |
118 if password == nil then | 119 if password == nil then |
119 return accounts:set(username, {}); | 120 return accounts:set(username, { created = now; updated = now; disabled = true }); |
120 end | 121 end |
121 local salt = generate_uuid(); | 122 local salt = generate_uuid(); |
122 local valid, stored_key, server_key = get_auth_db(password, salt, default_iteration_count); | 123 local valid, stored_key, server_key = get_auth_db(password, salt, default_iteration_count); |
123 if not valid then | 124 if not valid then |
124 return valid, stored_key; | 125 return valid, stored_key; |
125 end | 126 end |
126 local stored_key_hex = to_hex(stored_key); | 127 local stored_key_hex = to_hex(stored_key); |
127 local server_key_hex = to_hex(server_key); | 128 local server_key_hex = to_hex(server_key); |
128 local now = os.time(); | |
129 return accounts:set(username, { | 129 return accounts:set(username, { |
130 stored_key = stored_key_hex, server_key = server_key_hex, | 130 stored_key = stored_key_hex, server_key = server_key_hex, |
131 salt = salt, iteration_count = default_iteration_count, | 131 salt = salt, iteration_count = default_iteration_count, |
132 created = now, updated = now; | 132 created = now, updated = now; |
133 }); | 133 }); |