liquid_feedback_frontend
diff app/main/role/_action/request.lua @ 1309:32cc544d5a5b
Cumulative patch for upcoming frontend version 4
author | bsw/jbe |
---|---|
date | Sun Jul 15 14:07:29 2018 +0200 (2018-07-15) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/role/_action/request.lua Sun Jul 15 14:07:29 2018 +0200 1.3 @@ -0,0 +1,57 @@ 1.4 +if not app.session.member or app.session.member.role then 1.5 + return 1.6 +end 1.7 + 1.8 +local errors = 0 1.9 + 1.10 +if config.use_terms_checkboxes_role then 1.11 + for i, checkbox in ipairs(config.use_terms_checkboxes_role) do 1.12 + local accepted = param.get("use_terms_checkbox_" .. checkbox.name, atom.boolean) 1.13 + if not accepted then 1.14 + slot.put_into("error", checkbox.not_accepted_error) 1.15 + errors = errors + 1 1.16 + end 1.17 + end 1.18 +end 1.19 + 1.20 +local email = param.get("email") 1.21 + 1.22 +local members = Member:new_selector() 1.23 + :add_where{ "notify_email = ? OR notify_email_unconfirmed = ?", email } 1.24 + :exec() 1.25 + 1.26 +if #members > 0 then 1.27 + slot.select("error", function() 1.28 + slot.put_into("registration_register_email_invalid", "already_used") 1.29 + ui.tag{ content = _"This email address already been used. Please check your inbox for an invitation or contact us." } 1.30 + end) 1.31 + errors = errors + 1 1.32 +end 1.33 + 1.34 +local verification = RoleVerification:new() 1.35 +verification.requesting_member_id = app.session.member_id 1.36 +verification.requested = "now" 1.37 +verification.request_origin = json.object{ 1.38 + ip = request.get_header("X-Forwarded-For"), 1.39 + hostname = request.get_header("X-Forwarded-Host") 1.40 +} 1.41 +verification.request_data = json.object() 1.42 + 1.43 +for i, field in ipairs(config.role_registration.fields) do 1.44 + local value = param.get("verification_data_" .. field.name) 1.45 + if not value or #value < 1 then 1.46 + slot.put_into("self_registration__invalid_" .. field.name, "to_short") 1.47 + slot.select("error", function() 1.48 + ui.container{ content = _("Please enter: #{field_name}", { field_name = field.label }) } 1.49 + end) 1.50 + errors = errors + 1 1.51 + end 1.52 + value = string.gsub(value, "^%s+", "") 1.53 + value = string.gsub(value, "%s+$", "") 1.54 + value = string.gsub(value, "%s+", " ") 1.55 + verification.request_data[field.name] = value 1.56 +end 1.57 + 1.58 +verification:save() 1.59 + 1.60 +request.redirect{ external = encode.url { module = "member", view = "show", id = app.session.member_id } }