liquid_feedback_frontend
diff app/main/registration/_action/register.lua @ 1359:7532831a7618
Allow internal registration fields
author | bsw |
---|---|
date | Mon Aug 06 13:56:43 2018 +0200 (2018-08-06) |
parents | b0ed2b11ea28 |
children | 2ff3ae341a6e |
line diff
1.1 --- a/app/main/registration/_action/register.lua Mon Aug 06 13:42:37 2018 +0200 1.2 +++ b/app/main/registration/_action/register.lua Mon Aug 06 13:56:43 2018 +0200 1.3 @@ -113,76 +113,76 @@ 1.4 verification.request_data = json.object() 1.5 1.6 for i, field in ipairs(config.self_registration.fields) do 1.7 - if field.name == "date_of_birth" then 1.8 - local day = tonumber(param.get("verification_data_" .. field.name .. "_day")) 1.9 - local month = tonumber(param.get("verification_data_" .. field.name .. "_month")) 1.10 - local year = tonumber(param.get("verification_data_" .. field.name .. "_year")) 1.11 - local date = atom.date:new{ year = year, month = month, day = day } 1.12 - if date.invalid then 1.13 - slot.select("error", function() 1.14 - ui.container{ content = _"Please check date of birth" } 1.15 - slot.put_into("self_registration__invalid_" .. field.name, "invalid") 1.16 - end) 1.17 - errors = errors + 1 1.18 - end 1.19 - local today = atom.date:get_current() 1.20 - local date_16y_ago = atom.date:new{ year = today.year - 16, month = today.month, day = today.day } 1.21 - if date_16y_ago.invalid and today.month == 2 and today.day == 29 then 1.22 - date_16y_ago = atom.date:new{ year = today.year - 16, month = 2, day = 28 } 1.23 - end 1.24 - if date > date_16y_ago then 1.25 - request.redirect{ external = encode.url { module = "registration", view = "register_rejected_age" } } 1.26 - return 1.27 - end 1.28 - verification.request_data[field.name] = string.format("%04i-%02i-%02i", year, month, day) 1.29 - 1.30 - else 1.31 - local value = param.get("verification_data_" .. field.name) 1.32 - if not field.optional and (not value or (#value < 1 and (not manual_verification or field.name ~= "mobile_phone"))) then 1.33 - slot.put_into("self_registration__invalid_" .. field.name, "to_short") 1.34 - slot.select("error", function() 1.35 - ui.container{ content = _("Please enter: #{field_name}", { field_name = field.label }) } 1.36 - end) 1.37 - errors = errors + 1 1.38 - end 1.39 - if field.name == "fiscal_code" then 1.40 - value = string.upper(value) 1.41 - value = string.gsub(value, "[^A-Z0-9]", "") 1.42 - elseif field.name == "mobile_phone" then 1.43 - value = string.gsub(value, "[^0-9]", "") 1.44 - elseif field.type == "image" then 1.45 - if field.save_func then 1.46 - value = field.save_func(value) 1.47 + if not field.internal then 1.48 + if field.name == "date_of_birth" then 1.49 + local day = tonumber(param.get("verification_data_" .. field.name .. "_day")) 1.50 + local month = tonumber(param.get("verification_data_" .. field.name .. "_month")) 1.51 + local year = tonumber(param.get("verification_data_" .. field.name .. "_year")) 1.52 + local date = atom.date:new{ year = year, month = month, day = day } 1.53 + if date.invalid then 1.54 + slot.select("error", function() 1.55 + ui.container{ content = _"Please check date of birth" } 1.56 + slot.put_into("self_registration__invalid_" .. field.name, "invalid") 1.57 + end) 1.58 + errors = errors + 1 1.59 + end 1.60 + local today = atom.date:get_current() 1.61 + local date_16y_ago = atom.date:new{ year = today.year - 16, month = today.month, day = today.day } 1.62 + if date_16y_ago.invalid and today.month == 2 and today.day == 29 then 1.63 + date_16y_ago = atom.date:new{ year = today.year - 16, month = 2, day = 28 } 1.64 + end 1.65 + if date > date_16y_ago then 1.66 + request.redirect{ external = encode.url { module = "registration", view = "register_rejected_age" } } 1.67 + return 1.68 end 1.69 + verification.request_data[field.name] = string.format("%04i-%02i-%02i", year, month, day) 1.70 + 1.71 else 1.72 - value = string.gsub(value, "^%s+", "") 1.73 - value = string.gsub(value, "%s+$", "") 1.74 - value = string.gsub(value, "%s+", " ") 1.75 - end 1.76 - verification.request_data[field.name] = value 1.77 - end 1.78 -end 1.79 - 1.80 -local automatic_verification_possible = true 1.81 - 1.82 -local mobile_phone = verification.request_data.mobile_phone 1.83 - 1.84 -if not manual_verification then 1.85 - if config.self_registration.check_for_italien_mobile_phone then 1.86 - if not check_italian_mobile_phone_number(mobile_phone) then 1.87 - slot.select("error", function() 1.88 - ui.container{ content = _"Please check the mobile phone number (invalid format)" } 1.89 - end) 1.90 - errors = errors + 1 1.91 + local value = param.get("verification_data_" .. field.name) 1.92 + if not field.optional and (not value or (#value < 1 and (not manual_verification or field.name ~= "mobile_phone"))) then 1.93 + slot.put_into("self_registration__invalid_" .. field.name, "to_short") 1.94 + slot.select("error", function() 1.95 + ui.container{ content = _("Please enter: #{field_name}", { field_name = field.label }) } 1.96 + end) 1.97 + errors = errors + 1 1.98 + end 1.99 + if field.name == "fiscal_code" then 1.100 + value = string.upper(value) 1.101 + value = string.gsub(value, "[^A-Z0-9]", "") 1.102 + elseif field.name == "mobile_phone" then 1.103 + value = string.gsub(value, "[^0-9]", "") 1.104 + elseif field.type == "image" then 1.105 + if field.save_func then 1.106 + value = field.save_func(value) 1.107 + end 1.108 + else 1.109 + value = string.gsub(value, "^%s+", "") 1.110 + value = string.gsub(value, "%s+$", "") 1.111 + value = string.gsub(value, "%s+", " ") 1.112 + end 1.113 + verification.request_data[field.name] = value 1.114 end 1.115 end 1.116 1.117 - if config.self_registration.check_for_uk_mobile_phone then 1.118 - if not check_uk_mobile_phone_number(mobile_phone) then 1.119 - slot.select("error", function() 1.120 - ui.container{ content = _"Please check the mobile phone number (invalid format)" } 1.121 - end) 1.122 - errors = errors + 1 1.123 + local mobile_phone = verification.request_data.mobile_phone 1.124 + 1.125 + if not manual_verification then 1.126 + if config.self_registration.check_for_italien_mobile_phone then 1.127 + if not check_italian_mobile_phone_number(mobile_phone) then 1.128 + slot.select("error", function() 1.129 + ui.container{ content = _"Please check the mobile phone number (invalid format)" } 1.130 + end) 1.131 + errors = errors + 1 1.132 + end 1.133 + end 1.134 + 1.135 + if config.self_registration.check_for_uk_mobile_phone then 1.136 + if not check_uk_mobile_phone_number(mobile_phone) then 1.137 + slot.select("error", function() 1.138 + ui.container{ content = _"Please check the mobile phone number (invalid format)" } 1.139 + end) 1.140 + errors = errors + 1 1.141 + end 1.142 end 1.143 end 1.144 end