From b95406c413b9f91fd8bdf2b386c8e9edf525dedb Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 5 Jan 2017 17:39:15 +0100 Subject: mod_register: Allow 'title' and 'instructions' fields to be customized --- plugins/mod_register.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'plugins/mod_register.lua') diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index c376117f..f89efe20 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -41,16 +41,21 @@ local field_map = { date = { name = "date", type = "text-single", label = "Birth date" }; }; +local title = module:get_option_string("registration_title", + "Creating a new account"); +local instructions = module:get_option_string("registration_instructions", + "Choose a username and password for use with this service."); + local registration_form = dataform_new{ - title = "Creating a new account"; - instructions = "Choose a username and password for use with this service."; + title = title; + instructions = instructions; field_map.username; field_map.password; }; local registration_query = st.stanza("query", {xmlns = "jabber:iq:register"}) - :tag("instructions"):text("Choose a username and password for use with this service."):up() + :tag("instructions"):text(instructions):up() :tag("username"):up() :tag("password"):up(); -- cgit v1.2.3 From 56f3c13d17b6e98923bc914cc51ed95527ea0b55 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 6 Jan 2017 13:07:22 +0100 Subject: mod_register: Strip '+' char from field names without using length --- plugins/mod_register.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_register.lua') diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index f89efe20..7a57d65b 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -64,7 +64,7 @@ for _, field in ipairs(additional_fields) do registration_form[#registration_form + 1] = field; else if field:match("%+$") then - field = field:sub(1, #field - 1); + field = field:sub(1, -2); field_map[field].required = true; end -- cgit v1.2.3 From c29639e0db4b023bbebe3d6e134c52761a74d1a1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 6 Jan 2017 13:09:09 +0100 Subject: mod_register: Verify that fields are known to prevent traceback --- plugins/mod_register.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins/mod_register.lua') diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index 7a57d65b..9358eb64 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -63,6 +63,7 @@ for _, field in ipairs(additional_fields) do if type(field) == "table" then registration_form[#registration_form + 1] = field; else + elseif field_map[field] or field_map[field:sub(1, -2) then if field:match("%+$") then field = field:sub(1, -2); field_map[field].required = true; @@ -70,6 +71,8 @@ for _, field in ipairs(additional_fields) do registration_form[#registration_form + 1] = field_map[field]; registration_query:tag(field):up(); + else + module:log("error", "Unknown field %q", field); end end registration_query:add_child(registration_form:form()); -- cgit v1.2.3 From ef391bf6c46128a67c5cb408496ea51b6f0d3736 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 6 Jan 2017 13:14:17 +0100 Subject: mod_register: Fix syntax errors --- plugins/mod_register.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/mod_register.lua') diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index 9358eb64..ee3f88ba 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -62,8 +62,7 @@ local registration_query = st.stanza("query", {xmlns = "jabber:iq:register"}) for _, field in ipairs(additional_fields) do if type(field) == "table" then registration_form[#registration_form + 1] = field; - else - elseif field_map[field] or field_map[field:sub(1, -2) then + elseif field_map[field] or field_map[field:sub(1, -2)] then if field:match("%+$") then field = field:sub(1, -2); field_map[field].required = true; -- cgit v1.2.3