Software /
code /
prosody
Comparison
plugins/mod_admin_adhoc.lua @ 4993:5243b74a4cbb
Hopefully inert commit to clean up logging across a number of modules, removing all cases of concatenation when building log messages
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 23 Jul 2012 17:32:33 +0100 |
parent | 4956:bc26e6d519ae |
child | 5013:ab693eea0869 |
comparison
equal
deleted
inserted
replaced
4992:e79e4d1f75de | 4993:5243b74a4cbb |
---|---|
61 if (fields["password"] == fields["password-verify"]) and username and host then | 61 if (fields["password"] == fields["password-verify"]) and username and host then |
62 if usermanager_user_exists(username, host) then | 62 if usermanager_user_exists(username, host) then |
63 return { status = "completed", error = { message = "Account already exists" } }; | 63 return { status = "completed", error = { message = "Account already exists" } }; |
64 else | 64 else |
65 if usermanager_create_user(username, fields.password, host) then | 65 if usermanager_create_user(username, fields.password, host) then |
66 module:log("info", "Created new account " .. username.."@"..host); | 66 module:log("info", "Created new account %s@%s", username, host); |
67 return { status = "completed", info = "Account successfully created" }; | 67 return { status = "completed", info = "Account successfully created" }; |
68 else | 68 else |
69 return { status = "completed", error = { message = "Failed to write data to disk" } }; | 69 return { status = "completed", error = { message = "Failed to write data to disk" } }; |
70 end | 70 end |
71 end | 71 end |
72 else | 72 else |
73 module:log("debug", (fields.accountjid or "<nil>") .. " " .. (fields.password or "<nil>") .. " " | 73 module:log("debug", "Invalid data, password mismatch or empty username while creating account for %s", fields.accountjid or "<nil>"); |
74 .. (fields["password-verify"] or "<nil>")); | |
75 return { status = "completed", error = { message = "Invalid data.\nPassword mismatch, or empty username" } }; | 74 return { status = "completed", error = { message = "Invalid data.\nPassword mismatch, or empty username" } }; |
76 end | 75 end |
77 else | 76 else |
78 return { status = "executing", form = add_user_layout }, "executing"; | 77 return { status = "executing", form = add_user_layout }, "executing"; |
79 end | 78 end |
141 local failed = {}; | 140 local failed = {}; |
142 local succeeded = {}; | 141 local succeeded = {}; |
143 for _, aJID in ipairs(fields.accountjids) do | 142 for _, aJID in ipairs(fields.accountjids) do |
144 local username, host, resource = jid.split(aJID); | 143 local username, host, resource = jid.split(aJID); |
145 if (host == data.to) and usermanager_user_exists(username, host) and disconnect_user(aJID) and usermanager_create_user(username, nil, host) then | 144 if (host == data.to) and usermanager_user_exists(username, host) and disconnect_user(aJID) and usermanager_create_user(username, nil, host) then |
146 module:log("debug", "User " .. aJID .. " has been deleted"); | 145 module:log("debug", "User %s has been deleted", aJID); |
147 succeeded[#succeeded+1] = aJID; | 146 succeeded[#succeeded+1] = aJID; |
148 else | 147 else |
149 module:log("debug", "Tried to delete non-existant user "..aJID); | 148 module:log("debug", "Tried to delete non-existant user %s", aJID); |
150 failed[#failed+1] = aJID; | 149 failed[#failed+1] = aJID; |
151 end | 150 end |
152 end | 151 end |
153 return {status = "completed", info = (#succeeded ~= 0 and | 152 return {status = "completed", info = (#succeeded ~= 0 and |
154 "The following accounts were successfully deleted:\n"..t_concat(succeeded, "\n").."\n" or "").. | 153 "The following accounts were successfully deleted:\n"..t_concat(succeeded, "\n").."\n" or "").. |
163 local node, hostname, givenResource = jid.split(match_jid); | 162 local node, hostname, givenResource = jid.split(match_jid); |
164 local host = hosts[hostname]; | 163 local host = hosts[hostname]; |
165 local sessions = host.sessions[node] and host.sessions[node].sessions; | 164 local sessions = host.sessions[node] and host.sessions[node].sessions; |
166 for resource, session in pairs(sessions or {}) do | 165 for resource, session in pairs(sessions or {}) do |
167 if not givenResource or (resource == givenResource) then | 166 if not givenResource or (resource == givenResource) then |
168 module:log("debug", "Disconnecting "..node.."@"..hostname.."/"..resource); | 167 module:log("debug", "Disconnecting %s@%s/%s", node, hostname, resource); |
169 session:close(); | 168 session:close(); |
170 end | 169 end |
171 end | 170 end |
172 return true; | 171 return true; |
173 end | 172 end |