liquid_feedback_frontend

changeset 1812:fc3f15316a68

Better error handling also for creating new accounts
author bsw
date Thu Dec 02 13:33:05 2021 +0100 (2021-12-02)
parents c8fe2498a1af
children f9f3a657d348
files app/main/registration_admin/_action/update_verification.lua
line diff
     1.1 --- a/app/main/registration_admin/_action/update_verification.lua	Thu Dec 02 13:30:20 2021 +0100
     1.2 +++ b/app/main/registration_admin/_action/update_verification.lua	Thu Dec 02 13:33:05 2021 +0100
     1.3 @@ -50,6 +50,19 @@
     1.4    end
     1.5  end
     1.6  
     1.7 +local function check_db_error(db_error)
     1.8 +  if db_error then
     1.9 +    if db_error.is_kind_of("IntegrityConstraintViolation.UniqueViolation") then
    1.10 +      slot.select("error", function()
    1.11 +        ui.tag{ content = _"Identification unique violation: This identification is already in use for another member." }
    1.12 +      end )
    1.13 +      return false
    1.14 +    else
    1.15 +      error(db_error)
    1.16 +    end
    1.17 +  end
    1.18 +end
    1.19 +
    1.20  if verification.verified_member_id then
    1.21    
    1.22    local member = Member:by_id(verification.verified_member_id)
    1.23 @@ -66,21 +79,11 @@
    1.24    member.identification = identification
    1.25  
    1.26    member.notify_email = param.get("email")
    1.27 -  db_error = member:try_save()
    1.28 -  
    1.29 -  if db_error then
    1.30 -    if db_error.is_kind_of("IntegrityConstraintViolation.UniqueViolation") then
    1.31 -      slot.select("error", function()
    1.32 -        ui.tag{ content = _"Identification unique violation: This identification is already in use for another member." }
    1.33 -      end )
    1.34 -      return false
    1.35 -    else
    1.36 -      error(db_error)
    1.37 -    end
    1.38 -  end
    1.39 -  
    1.40 +
    1.41 +  check_db_error(member:try_save())
    1.42 +
    1.43    update_data()
    1.44 -  
    1.45 +
    1.46    verification:save()
    1.47  
    1.48    if param.get("invite") then
    1.49 @@ -98,7 +101,7 @@
    1.50    local member = Member:by_id(verification.requesting_member_id)
    1.51    member.identification = param.get("identification")
    1.52    member.notify_email = param.get("email")
    1.53 -  member:save()
    1.54 +  check_db_error(member:try_save())
    1.55  
    1.56    if config.self_registration.manual_invitation then
    1.57      local function secret_token()

Impressum / About Us