Comparison

plugins/mod_register.lua @ 1184:fa6df7e83fb3

mod_register: Fire events and log on account creation/deletion
author Matthew Wild <mwild1@gmail.com>
date Tue, 19 May 2009 11:53:34 +0100
parent 1042:a3d77353c18a
child 1189:63ed3902f357
comparison
equal deleted inserted replaced
1183:565e16ee0c74 1184:fa6df7e83fb3
58 -- TODO unsubscribe 58 -- TODO unsubscribe
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);
64 module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register" });
63 else 65 else
64 local username = query:child_with_name("username"); 66 local username = query:child_with_name("username");
65 local password = query:child_with_name("password"); 67 local password = query:child_with_name("password");
66 if username and password then 68 if username and password then
67 -- FIXME shouldn't use table.concat 69 -- FIXME shouldn't use table.concat
141 if usermanager_user_exists(username, session.host) then 143 if usermanager_user_exists(username, session.host) then
142 session.send(st.error_reply(stanza, "cancel", "conflict")); 144 session.send(st.error_reply(stanza, "cancel", "conflict"));
143 else 145 else
144 if usermanager_create_user(username, password, session.host) then 146 if usermanager_create_user(username, password, session.host) then
145 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);
149 module:fire_event("user-registered", {
150 username = username, host = session.host, source = "mod_register" });
146 else 151 else
147 -- TODO unable to write file, file may be locked, etc, what's the correct error? 152 -- TODO unable to write file, file may be locked, etc, what's the correct error?
148 session.send(st.error_reply(stanza, "wait", "internal-server-error")); 153 session.send(st.error_reply(stanza, "wait", "internal-server-error"));
149 end 154 end
150 end 155 end