Changeset

1235:9277e0a3922f

mod_register_web: Support additional registration fields
author Kim Alvefur <zash@zash.se>
date Sat, 30 Nov 2013 22:59:27 +0100
parents 1234:da39ba4047a7
children 1236:59332e0bfbdc
files mod_register_web/mod_register_web.lua
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_register_web/mod_register_web.lua	Sat Nov 30 22:10:41 2013 +0100
+++ b/mod_register_web/mod_register_web.lua	Sat Nov 30 22:59:27 2013 +0100
@@ -3,6 +3,12 @@
 local usermanager = require "core.usermanager";
 local http = require "util.http";
 
+local extra_fields = {
+	nick = true; name = true; first = true; last = true; email = true;
+	address = true; city = true; state = true; zip = true;
+	phone = true; url = true; date = true;
+}
+
 function template(data)
 	-- Like util.template, but deals with plain text
 	return { apply = function(values) return (data:gsub("{([^}]+)}", values)); end }
@@ -110,6 +116,16 @@
 	end
 	local ok, err = usermanager.create_user(prepped_username, form.password, module.host);
 	if ok then
+		local extra_data = {};
+		for field in pairs(extra_fields) do
+			local field_value = form[field];
+			if field_value and #field_value > 0 then
+				extra_data[field] = field_value;
+			end
+		end
+		if next(first) ~= nil then
+			datamanager.store(prepped_username, module.host, "account_details", extra_data);
+		end
 		module:fire_event("user-registered", {
 			username = prepped_username,
 			host = module.host,