Mercurial > prosody-hg
comparison plugins/mod_admin_adhoc.lua @ 11200:bf8f2da84007
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 05 Nov 2020 22:31:25 +0100 |
| parents | 46b456ed12bd |
| children | 21a1b9fb08a1 |
comparison
equal
deleted
inserted
replaced
| 11199:6c7c50a4de32 | 11200:bf8f2da84007 |
|---|---|
| 57 | 57 |
| 58 local add_user_command_handler = adhoc_simple(add_user_layout, function(fields, err) | 58 local add_user_command_handler = adhoc_simple(add_user_layout, function(fields, err) |
| 59 if err then | 59 if err then |
| 60 return generate_error_message(err); | 60 return generate_error_message(err); |
| 61 end | 61 end |
| 62 local username, host, resource = jid.split(fields.accountjid); | 62 local username, host = jid.split(fields.accountjid); |
| 63 if module_host ~= host then | 63 if module_host ~= host then |
| 64 return { status = "completed", error = { message = "Trying to add a user on " .. host .. " but command was sent to " .. module_host}}; | 64 return { status = "completed", error = { message = "Trying to add a user on " .. host .. " but command was sent to " .. module_host}}; |
| 65 end | 65 end |
| 66 if (fields["password"] == fields["password-verify"]) and username and host then | 66 if (fields["password"] == fields["password-verify"]) and username and host then |
| 67 if usermanager_user_exists(username, host) then | 67 if usermanager_user_exists(username, host) then |
| 92 | 92 |
| 93 local change_user_password_command_handler = adhoc_simple(change_user_password_layout, function(fields, err) | 93 local change_user_password_command_handler = adhoc_simple(change_user_password_layout, function(fields, err) |
| 94 if err then | 94 if err then |
| 95 return generate_error_message(err); | 95 return generate_error_message(err); |
| 96 end | 96 end |
| 97 local username, host, resource = jid.split(fields.accountjid); | 97 local username, host = jid.split(fields.accountjid); |
| 98 if module_host ~= host then | 98 if module_host ~= host then |
| 99 return { | 99 return { |
| 100 status = "completed", | 100 status = "completed", |
| 101 error = { | 101 error = { |
| 102 message = "Trying to change the password of a user on " .. host .. " but command was sent to " .. module_host | 102 message = "Trying to change the password of a user on " .. host .. " but command was sent to " .. module_host |
| 134 return generate_error_message(err); | 134 return generate_error_message(err); |
| 135 end | 135 end |
| 136 local failed = {}; | 136 local failed = {}; |
| 137 local succeeded = {}; | 137 local succeeded = {}; |
| 138 for _, aJID in ipairs(fields.accountjids) do | 138 for _, aJID in ipairs(fields.accountjids) do |
| 139 local username, host, resource = jid.split(aJID); | 139 local username, host = jid.split(aJID); |
| 140 if (host == module_host) and usermanager_user_exists(username, host) and usermanager_delete_user(username, host) then | 140 if (host == module_host) and usermanager_user_exists(username, host) and usermanager_delete_user(username, host) then |
| 141 module:log("debug", "User %s has been deleted", aJID); | 141 module:log("debug", "User %s has been deleted", aJID); |
| 142 succeeded[#succeeded+1] = aJID; | 142 succeeded[#succeeded+1] = aJID; |
| 143 else | 143 else |
| 144 module:log("debug", "Tried to delete non-existant user %s", aJID); | 144 module:log("debug", "Tried to delete non-existant user %s", aJID); |
| 178 return generate_error_message(err); | 178 return generate_error_message(err); |
| 179 end | 179 end |
| 180 local failed = {}; | 180 local failed = {}; |
| 181 local succeeded = {}; | 181 local succeeded = {}; |
| 182 for _, aJID in ipairs(fields.accountjids) do | 182 for _, aJID in ipairs(fields.accountjids) do |
| 183 local username, host, resource = jid.split(aJID); | 183 local username, host = jid.split(aJID); |
| 184 if (host == module_host) and usermanager_user_exists(username, host) and disconnect_user(aJID) then | 184 if (host == module_host) and usermanager_user_exists(username, host) and disconnect_user(aJID) then |
| 185 succeeded[#succeeded+1] = aJID; | 185 succeeded[#succeeded+1] = aJID; |
| 186 else | 186 else |
| 187 failed[#failed+1] = aJID; | 187 failed[#failed+1] = aJID; |
| 188 end | 188 end |
| 210 | 210 |
| 211 local get_user_password_handler = adhoc_simple(get_user_password_layout, function(fields, err) | 211 local get_user_password_handler = adhoc_simple(get_user_password_layout, function(fields, err) |
| 212 if err then | 212 if err then |
| 213 return generate_error_message(err); | 213 return generate_error_message(err); |
| 214 end | 214 end |
| 215 local user, host, resource = jid.split(fields.accountjid); | 215 local user, host = jid.split(fields.accountjid); |
| 216 local accountjid; | 216 local accountjid; |
| 217 local password; | 217 local password; |
| 218 if host ~= module_host then | 218 if host ~= module_host then |
| 219 return { status = "completed", error = { message = "Tried to get password for a user on " .. host .. " but command was sent to " .. module_host } }; | 219 return { status = "completed", error = { message = "Tried to get password for a user on " .. host .. " but command was sent to " .. module_host } }; |
| 220 elseif usermanager_user_exists(user, host) then | 220 elseif usermanager_user_exists(user, host) then |
| 241 local get_user_roster_handler = adhoc_simple(get_user_roster_layout, function(fields, err) | 241 local get_user_roster_handler = adhoc_simple(get_user_roster_layout, function(fields, err) |
| 242 if err then | 242 if err then |
| 243 return generate_error_message(err); | 243 return generate_error_message(err); |
| 244 end | 244 end |
| 245 | 245 |
| 246 local user, host, resource = jid.split(fields.accountjid); | 246 local user, host = jid.split(fields.accountjid); |
| 247 if host ~= module_host then | 247 if host ~= module_host then |
| 248 return { status = "completed", error = { message = "Tried to get roster for a user on " .. host .. " but command was sent to " .. module_host } }; | 248 return { status = "completed", error = { message = "Tried to get roster for a user on " .. host .. " but command was sent to " .. module_host } }; |
| 249 elseif not usermanager_user_exists(user, host) then | 249 elseif not usermanager_user_exists(user, host) then |
| 250 return { status = "completed", error = { message = "User does not exist" } }; | 250 return { status = "completed", error = { message = "User does not exist" } }; |
| 251 end | 251 end |
| 390 | 390 |
| 391 local flags = {}; | 391 local flags = {}; |
| 392 if session.cert_identity_status == "valid" then | 392 if session.cert_identity_status == "valid" then |
| 393 flags[#flags+1] = "authenticated"; | 393 flags[#flags+1] = "authenticated"; |
| 394 end | 394 end |
| 395 if session.dialback_key then | |
| 396 flags[#flags+1] = "dialback"; | |
| 397 end | |
| 398 if session.external_auth then | |
| 399 flags[#flags+1] = "SASL"; | |
| 400 end | |
| 395 if session.secure then | 401 if session.secure then |
| 396 flags[#flags+1] = "encrypted"; | 402 flags[#flags+1] = "encrypted"; |
| 397 end | 403 end |
| 398 if session.compressed then | 404 if session.compressed then |
| 399 flags[#flags+1] = "compressed"; | 405 flags[#flags+1] = "compressed"; |
| 402 flags[#flags+1] = "sm"; | 408 flags[#flags+1] = "sm"; |
| 403 end | 409 end |
| 404 if session.ip and session.ip:match(":") then | 410 if session.ip and session.ip:match(":") then |
| 405 flags[#flags+1] = "IPv6"; | 411 flags[#flags+1] = "IPv6"; |
| 406 end | 412 end |
| 413 if session.incoming and session.outgoing then | |
| 414 flags[#flags+1] = "bidi"; | |
| 415 elseif session.is_bidi or session.bidi_session then | |
| 416 flags[#flags+1] = "bidi"; | |
| 417 end | |
| 418 | |
| 407 line[#line+1] = "("..t_concat(flags, ", ")..")"; | 419 line[#line+1] = "("..t_concat(flags, ", ")..")"; |
| 408 | 420 |
| 409 return t_concat(line, " "); | 421 return t_concat(line, " "); |
| 410 end | 422 end |
| 411 | 423 |
