liquid_feedback_frontend
diff app/main/registration_admin/_action/update_verification.lua @ 1843:b01d9920371b
merge
author | jbe |
---|---|
date | Thu Feb 03 15:57:22 2022 +0100 (2022-02-03) |
parents | baa87c3780ad |
children |
line diff
1.1 --- a/app/main/registration_admin/_action/update_verification.lua Thu Feb 03 15:54:23 2022 +0100 1.2 +++ b/app/main/registration_admin/_action/update_verification.lua Thu Feb 03 15:57:22 2022 +0100 1.3 @@ -12,7 +12,7 @@ 1.4 value = string.gsub(value, "[^0-9]", "") 1.5 elseif field.name == "unit" then 1.6 value = string.gsub(value, "[^0-9]", "") 1.7 - if old_verification_data.unit and old_verification_data.unit ~= "" then 1.8 + if old_verification_data.unit and old_verification_data.unit ~= "" and old_verification_data.unit ~= value then 1.9 local old_unit_privilege = Privilege:by_pk(old_verification_data.unit, verification.requesting_member_id) 1.10 if old_unit_privilege then 1.11 old_unit_privilege:destroy() 1.12 @@ -50,22 +50,44 @@ 1.13 end 1.14 end 1.15 1.16 +local function check_db_error(db_error) 1.17 + if db_error then 1.18 + if db_error:is_kind_of("IntegrityConstraintViolation.UniqueViolation") then 1.19 + slot.select("error", function() 1.20 + ui.tag{ content = _"Identification unique violation: This identification is already in use for another member." } 1.21 + end ) 1.22 + return false 1.23 + else 1.24 + error(db_error) 1.25 + end 1.26 + end 1.27 +end 1.28 + 1.29 if verification.verified_member_id then 1.30 1.31 local member = Member:by_id(verification.verified_member_id) 1.32 1.33 + local identification = param.get("identification") 1.34 + if identification and #identification == 0 then 1.35 + identification = nil 1.36 + end 1.37 + member.identification = identification 1.38 + 1.39 + member.notify_email = param.get("email") 1.40 + 1.41 + local success = check_db_error(member:try_save()) 1.42 + if not success then 1.43 + return false 1.44 + end 1.45 + 1.46 + update_data() 1.47 + 1.48 + verification:save() 1.49 + 1.50 if param.get("cancel") then 1.51 db:query({ "SELECT delete_member(?)", member.id }) 1.52 return 1.53 end 1.54 - 1.55 - member.identification = param.get("identification") 1.56 - member.notify_email = param.get("email") 1.57 - member:save() 1.58 - 1.59 - update_data() 1.60 - 1.61 - verification:save() 1.62 1.63 if param.get("invite") then 1.64 member:send_invitation() 1.65 @@ -80,9 +102,19 @@ 1.66 elseif param.get("accredit") then 1.67 1.68 local member = Member:by_id(verification.requesting_member_id) 1.69 - member.identification = param.get("identification") 1.70 + 1.71 + local identification = param.get("identification") 1.72 + if identification and #identification == 0 then 1.73 + identification = nil 1.74 + end 1.75 + member.identification = identification 1.76 + 1.77 member.notify_email = param.get("email") 1.78 - member:save() 1.79 + 1.80 + local success = check_db_error(member:try_save()) 1.81 + if not success then 1.82 + return false 1.83 + end 1.84 1.85 if config.self_registration.manual_invitation then 1.86 local function secret_token()