liquid_feedback_frontend
diff app/main/registration/_action/register.lua @ 1731:899fdfb23465
Modified workflow of automatic verification
| author | bsw |
|---|---|
| date | Thu Sep 30 10:04:31 2021 +0200 (2021-09-30) |
| parents | c91d97d1f5ba |
| children | aebc3b064f85 |
line diff
1.1 --- a/app/main/registration/_action/register.lua Thu Sep 23 18:21:25 2021 +0200 1.2 +++ b/app/main/registration/_action/register.lua Thu Sep 30 10:04:31 2021 +0200 1.3 @@ -282,17 +282,19 @@ 1.4 table.insert(manual_check_reasons, "User requested manual verification (during step 1)") 1.5 end 1.6 1.7 -if not config.self_registration.sms_id then 1.8 - table.insert(manual_check_reasons, "User requested manual verification (during step 1)") 1.9 +if config.self_registration.sms_id then 1.10 + local existing_verifications = Verification:new_selector() 1.11 + :add_where{ "request_data->>'mobile_phone' = ?", mobile_phone } 1.12 + :add_where("comment ilike '%SMS code%'") 1.13 + :exec() 1.14 + 1.15 + if #existing_verifications > 0 then 1.16 + table.insert(manual_check_reasons, "mobile phone number already used before") 1.17 + end 1.18 end 1.19 1.20 -local existing_verifications = Verification:new_selector() 1.21 - :add_where{ "request_data->>'mobile_phone' = ?", mobile_phone } 1.22 - :add_where("comment ilike '%SMS code%'") 1.23 - :exec() 1.24 - 1.25 -if #existing_verifications > 0 then 1.26 - table.insert(manual_check_reasons, "mobile phone number already used before") 1.27 +if config.self_registration.force_manual_check then 1.28 + table.insert(manual_check_reasons, "Manual check enforced by configuration") 1.29 end 1.30 1.31 if #manual_check_reasons > 0 then 1.32 @@ -301,13 +303,12 @@ 1.33 verification:save() 1.34 request.redirect{ external = encode.url { module = "registration", view = "register_manual_check_needed" } } 1.35 1.36 -else 1.37 +elseif config.self_registration.sms_id then 1.38 local pin = multirand.string(6, "0123456789") 1.39 verification.request_data.sms_code = pin 1.40 verification.request_data.sms_code_tries = 3 1.41 local sms_text = config.self_registration.sms_text 1.42 local sms_text = string.gsub(sms_text, "{PIN}", pin) 1.43 - print("SMS Code: " .. sms_text) 1.44 local phone_number 1.45 if config.self_registration.sms_strip_leading_zero then 1.46 phone_number = string.match(verification.request_data.mobile_phone, "0(.+)") 1.47 @@ -331,9 +332,7 @@ 1.48 1.49 local params_string = table.concat(params_list, "&") 1.50 local url = "http://gateway.any-sms.biz/send_sms.php?" .. params_string 1.51 - print("curl " .. url) 1.52 local output, err, status = extos.pfilter(nil, "curl", url) 1.53 - print(output) 1.54 verification.request_data.sms_code_sent_status = output 1.55 if not string.match(output, "^err:0") then 1.56 verification.comment = (verification.comment or "").. " /// Manual verification needed: sending SMS failed (" .. output .. ")" 1.57 @@ -344,6 +343,17 @@ 1.58 verification.comment = (verification.comment or "") .. " /// SMS code " .. pin .. " sent" 1.59 verification:save() 1.60 request.redirect{ external = encode.url { module = "registration", view = "register_enter_pin", id = verification.id } } 1.61 + 1.62 +else 1.63 + local success = execute.action{ 1.64 + module = "registration", action = "_verify", params = { 1.65 + verification = verification 1.66 + } 1.67 + } 1.68 + if success == "ok" then 1.69 + request.redirect{ external = encode.url { module = "registration", view = "register_completed" } } 1.70 + end 1.71 + 1.72 end 1.73 1.74