Software /
code /
prosody
Comparison
plugins/mod_register.lua @ 1189:63ed3902f357
mod_register: Attach session to user-registered and user-deregistered events
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 21 May 2009 15:52:20 +0100 |
parent | 1184:fa6df7e83fb3 |
child | 1523:841d61be198f |
comparison
equal
deleted
inserted
replaced
1188:fa48e69c4786 | 1189:63ed3902f357 |
---|---|
59 end | 59 end |
60 end | 60 end |
61 end | 61 end |
62 datamanager.store(username, host, "accounts", nil); -- delete accounts datastore at the end | 62 datamanager.store(username, host, "accounts", nil); -- delete accounts datastore at the end |
63 module:log("info", "User removed their account: %s@%s", username, host); | 63 module:log("info", "User removed their account: %s@%s", username, host); |
64 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register" }); | 64 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); |
65 else | 65 else |
66 local username = query:child_with_name("username"); | 66 local username = query:child_with_name("username"); |
67 local password = query:child_with_name("password"); | 67 local password = query:child_with_name("password"); |
68 if username and password then | 68 if username and password then |
69 -- FIXME shouldn't use table.concat | 69 -- FIXME shouldn't use table.concat |
145 else | 145 else |
146 if usermanager_create_user(username, password, session.host) then | 146 if usermanager_create_user(username, password, session.host) then |
147 session.send(st.reply(stanza)); -- user created! | 147 session.send(st.reply(stanza)); -- user created! |
148 module:log("info", "User account created: %s@%s", username, session.host); | 148 module:log("info", "User account created: %s@%s", username, session.host); |
149 module:fire_event("user-registered", { | 149 module:fire_event("user-registered", { |
150 username = username, host = session.host, source = "mod_register" }); | 150 username = username, host = session.host, source = "mod_register", |
151 session = session }); | |
151 else | 152 else |
152 -- TODO unable to write file, file may be locked, etc, what's the correct error? | 153 -- TODO unable to write file, file may be locked, etc, what's the correct error? |
153 session.send(st.error_reply(stanza, "wait", "internal-server-error")); | 154 session.send(st.error_reply(stanza, "wait", "internal-server-error")); |
154 end | 155 end |
155 end | 156 end |