diff options
author | Kim Alvefur <zash@zash.se> | 2016-11-02 13:08:12 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-11-02 13:08:12 +0100 |
commit | a608cc50da05ada72b0eef29ed8112f94b5c2ba2 (patch) | |
tree | a89d5435977581d468443ea67673c737defc6a0c /plugins | |
parent | 409492416d1881a4c4d97647b666ce2134271235 (diff) | |
download | prosody-a608cc50da05ada72b0eef29ed8112f94b5c2ba2.tar.gz prosody-a608cc50da05ada72b0eef29ed8112f94b5c2ba2.zip |
mod_register: Additional logging for various registration failure cases
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_register.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index df833cad..8929529e 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -204,6 +204,7 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) local log = session.log or module._log; if not(allow_registration) or session.type ~= "c2s_unauthed" then + log("debug", "Attempted registration when disabled or already authenticated"); session.send(st.error_reply(stanza, "cancel", "service-unavailable")); else local query = stanza.tags[1]; @@ -217,6 +218,10 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) else local data, errors = parse_response(query); if errors then + log("debug", "Error parsing registration form:"); + for field, err in pairs(errors) do + log("debug", "Field %q: %s", field, err); + end session.send(st.error_reply(stanza, "modify", "not-acceptable")); else -- Check that the user is not blacklisted or registering too often @@ -227,6 +232,7 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) return true; elseif min_seconds_between_registrations and not whitelisted_ips[session.ip] then if not check_throttle(session.ip) then + log("debug", "Registrations over limit for ip %s", session.ip or "?"); session.send(st.error_reply(stanza, "wait", "not-acceptable")); return true; end @@ -235,20 +241,24 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) data.username, data.password = nil, nil; local host = module.host; if not username or username == "" then + log("debug", "The requested username is invalid."); session.send(st.error_reply(stanza, "modify", "not-acceptable", "The requested username is invalid.")); return true; end local user = { username = username , host = host, allowed = true } module:fire_event("user-registering", user); if not user.allowed then + log("debug", "Registration disallowed by module"); session.send(st.error_reply(stanza, "modify", "not-acceptable", "The requested username is forbidden.")); elseif usermanager_user_exists(username, host) then + log("debug", "Attempt to register with existing username"); session.send(st.error_reply(stanza, "cancel", "conflict", "The requested username already exists.")); else -- TODO unable to write file, file may be locked, etc, what's the correct error? local error_reply = st.error_reply(stanza, "wait", "internal-server-error", "Failed to write data to disk."); if usermanager_create_user(username, password, host) then if next(data) and not account_details:set(username, data) then + log("debug", "Could not store extra details"); usermanager_delete_user(username, host); session.send(error_reply); return true; @@ -259,6 +269,7 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event) username = username, host = host, source = "mod_register", session = session }); else + log("debug", "Could not create user"); session.send(error_reply); end end |