aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_register_ibr.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mod_register_ibr.lua')
-rw-r--r--plugins/mod_register_ibr.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/mod_register_ibr.lua b/plugins/mod_register_ibr.lua
index bbe7581d..2f220658 100644
--- a/plugins/mod_register_ibr.lua
+++ b/plugins/mod_register_ibr.lua
@@ -25,6 +25,7 @@ end);
local account_details = module:open_store("account_details");
local field_map = {
+ FORM_TYPE = { name = "FORM_TYPE", type = "hidden", value = "jabber:iq:register" };
username = { name = "username", type = "text-single", label = "Username", required = true };
password = { name = "password", type = "text-private", label = "Password", required = true };
nick = { name = "nick", type = "text-single", label = "Nickname" };
@@ -50,6 +51,7 @@ local registration_form = dataform_new{
title = title;
instructions = instructions;
+ field_map.FORM_TYPE;
field_map.username;
field_map.password;
};
@@ -166,7 +168,8 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event)
module:fire_event("user-registering", user);
if not user.allowed then
log("debug", "Registration disallowed by module: %s", user.reason or "no reason given");
- session.send(st.error_reply(stanza, "modify", "not-acceptable", user.reason));
+ -- TODO This could use util.error
+ session.send(st.error_reply(stanza, user.error_type or "modify", user.error_condition or "not-acceptable", user.reason));
return true;
end
@@ -176,14 +179,13 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event)
return true;
end
- -- 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
+ local created, err = usermanager_create_user(username, password, host);
+ if created then
data.registered = os.time();
if not account_details:set(username, data) then
log("debug", "Could not store extra details");
usermanager_delete_user(username, host);
- session.send(error_reply);
+ session.send(st.error_reply(stanza, "wait", "internal-server-error", "Failed to write data to disk."));
return true;
end
session.send(st.reply(stanza)); -- user created!
@@ -192,8 +194,8 @@ 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);
+ log("debug", "Could not create user", err);
+ session.send(st.error_reply(stanza, "cancel", "feature-not-implemented", err));
end
return true;
end);