liquid_feedback_frontend

changeset 1731:899fdfb23465

Modified workflow of automatic verification
author bsw
date Thu Sep 30 10:04:31 2021 +0200 (2021-09-30)
parents b2868d84275e
children 80c101b08bf9
files app/main/registration/_action/register.lua app/main/registration/_action/register_pin.lua app/main/registration_admin/verification_accredited.lua
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  
     2.1 --- a/app/main/registration/_action/register_pin.lua	Thu Sep 23 18:21:25 2021 +0200
     2.2 +++ b/app/main/registration/_action/register_pin.lua	Thu Sep 30 10:04:31 2021 +0200
     2.3 @@ -29,43 +29,12 @@
     2.4  
     2.5  verification.comment = (verification.comment or "").. " /// User entered correct PIN code"
     2.6  
     2.7 -verification.verified = "now"
     2.8 -verification.verification_data = verification.request_data
     2.9 -
    2.10 -local identification = config.self_registration.identification_func(verification.request_data)
    2.11 -
    2.12 -local members_with_same_identification = Member:new_selector()
    2.13 -  :add_where{ "identification = ?", identification }
    2.14 -  :exec()
    2.15 -
    2.16 -if #members_with_same_identification > 0 then
    2.17 -  verification.comment = (verification.comment or "").. " /// Manual verification needed: user with same name already exists"
    2.18 -  verification:save()
    2.19 -  request.redirect{ external = encode.url { module = "registration", view = "register_manual_check_needed" } }
    2.20 -  return false
    2.21 +local success = execute.action{
    2.22 +  module = "registration", action = "_verify", params = {
    2.23 +    verification = verification
    2.24 +  }
    2.25 +}
    2.26 +if success == "ok" then
    2.27 +  request.redirect{ external = encode.url { module = "registration", view = "register_completed" } } 
    2.28  end
    2.29  
    2.30 -local member = Member:by_id(verification.requesting_member_id)
    2.31 -
    2.32 -member.identification = identification
    2.33 -member.notify_email = verification.request_data.email
    2.34 -
    2.35 -member:send_invitation()
    2.36 -
    2.37 -for i, unit_id in ipairs(config.self_registration.grant_privileges_for_unit_ids) do
    2.38 -  local privilege = Privilege:new()
    2.39 -  privilege.member_id = member.id
    2.40 -  privilege.unit_id = unit_id
    2.41 -  privilege.initiative_right = true
    2.42 -  privilege.voting_right = true
    2.43 -  privilege:save()
    2.44 -end
    2.45 -
    2.46 -verification.verified_member_id = member.id
    2.47 -
    2.48 -verification.comment = (verification.comment or "").. " /// Account created"
    2.49 -
    2.50 -verification:save()
    2.51 -
    2.52 -
    2.53 -request.redirect{ external = encode.url { module = "registration", view = "register_completed" } } 
     3.1 --- a/app/main/registration_admin/verification_accredited.lua	Thu Sep 23 18:21:25 2021 +0200
     3.2 +++ b/app/main/registration_admin/verification_accredited.lua	Thu Sep 30 10:04:31 2021 +0200
     3.3 @@ -87,7 +87,7 @@
     3.4                        slot.put(" ")
     3.5                        ui.tag{ content = state } 
     3.6                      elseif record.verified then
     3.7 -                      ui.tag{ content = _"SMS" }
     3.8 +                      ui.tag{ content = _"automatically verified" }
     3.9                      end
    3.10                      
    3.11                    end

Impressum / About Us