Software / code / prosody
Comparison
plugins/mod_register.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Fri, 09 Aug 2013 17:48:21 +0200 |
| parent | 5763:0e52f1d5ca71 |
| child | 7017:ff734a602886 |
comparison
equal
deleted
inserted
replaced
| 5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
|---|---|
| 1 -- Prosody IM | 1 -- Prosody IM |
| 2 -- Copyright (C) 2008-2010 Matthew Wild | 2 -- Copyright (C) 2008-2010 Matthew Wild |
| 3 -- Copyright (C) 2008-2010 Waqas Hussain | 3 -- Copyright (C) 2008-2010 Waqas Hussain |
| 4 -- | 4 -- |
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 | 9 |
| 100 local old_session_close = session.close; | 100 local old_session_close = session.close; |
| 101 session.close = function(session, ...) | 101 session.close = function(session, ...) |
| 102 session.send(st.reply(stanza)); | 102 session.send(st.reply(stanza)); |
| 103 return old_session_close(session, ...); | 103 return old_session_close(session, ...); |
| 104 end | 104 end |
| 105 | 105 |
| 106 local ok, err = usermanager_delete_user(username, host); | 106 local ok, err = usermanager_delete_user(username, host); |
| 107 | 107 |
| 108 if not ok then | 108 if not ok then |
| 109 module:log("debug", "Removing user account %s@%s failed: %s", username, host, err); | 109 module:log("debug", "Removing user account %s@%s failed: %s", username, host, err); |
| 110 session.close = old_session_close; | 110 session.close = old_session_close; |
| 111 session.send(st.error_reply(stanza, "cancel", "service-unavailable", err)); | 111 session.send(st.error_reply(stanza, "cancel", "service-unavailable", err)); |
| 112 return true; | 112 return true; |
| 113 end | 113 end |
| 114 | 114 |
| 115 module:log("info", "User removed their account: %s@%s", username, host); | 115 module:log("info", "User removed their account: %s@%s", username, host); |
| 116 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); | 116 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); |
| 117 else | 117 else |
| 118 local username = nodeprep(query:get_child_text("username")); | 118 local username = nodeprep(query:get_child_text("username")); |
| 119 local password = query:get_child_text("password"); | 119 local password = query:get_child_text("password"); |
| 204 if not recent_ips[session.ip] then | 204 if not recent_ips[session.ip] then |
| 205 recent_ips[session.ip] = { time = os_time(), count = 1 }; | 205 recent_ips[session.ip] = { time = os_time(), count = 1 }; |
| 206 else | 206 else |
| 207 local ip = recent_ips[session.ip]; | 207 local ip = recent_ips[session.ip]; |
| 208 ip.count = ip.count + 1; | 208 ip.count = ip.count + 1; |
| 209 | 209 |
| 210 if os_time() - ip.time < min_seconds_between_registrations then | 210 if os_time() - ip.time < min_seconds_between_registrations then |
| 211 ip.time = os_time(); | 211 ip.time = os_time(); |
| 212 session.send(st.error_reply(stanza, "wait", "not-acceptable")); | 212 session.send(st.error_reply(stanza, "wait", "not-acceptable")); |
| 213 return true; | 213 return true; |
| 214 end | 214 end |