liquid_feedback_frontend
annotate app/main/registration/_action/_verify.lua @ 1734:aebc3b064f85
Automatically add verified member to selected unit
author | bsw |
---|---|
date | Thu Sep 30 22:39:46 2021 +0200 (2021-09-30) |
parents | 30017c87369e |
children | e39206c7c4ea |
rev | line source |
---|---|
bsw@1733 | 1 local verification = param.get("verification", "table") |
bsw@1733 | 2 |
bsw@1733 | 3 verification.verified = "now" |
bsw@1733 | 4 verification.verification_data = verification.request_data |
bsw@1733 | 5 |
bsw@1733 | 6 local identification = config.self_registration.identification_func(verification.request_data) |
bsw@1733 | 7 |
bsw@1733 | 8 local members_with_same_identification = Member:new_selector() |
bsw@1733 | 9 :add_where{ "identification = ?", identification } |
bsw@1733 | 10 :exec() |
bsw@1733 | 11 |
bsw@1733 | 12 if #members_with_same_identification > 0 then |
bsw@1733 | 13 verification.comment = (verification.comment or "").. " /// Manual verification needed: user with same name already exists" |
bsw@1733 | 14 verification:save() |
bsw@1733 | 15 request.redirect{ external = encode.url { module = "registration", view = "register_manual_check_needed" } } |
bsw@1733 | 16 return false |
bsw@1733 | 17 end |
bsw@1733 | 18 |
bsw@1733 | 19 local member = Member:by_id(verification.requesting_member_id) |
bsw@1733 | 20 |
bsw@1733 | 21 member.identification = identification |
bsw@1733 | 22 member.notify_email = verification.request_data.email |
bsw@1733 | 23 |
bsw@1733 | 24 member:send_invitation() |
bsw@1733 | 25 |
bsw@1733 | 26 for i, unit_id in ipairs(config.self_registration.grant_privileges_for_unit_ids) do |
bsw@1733 | 27 local privilege = Privilege:new() |
bsw@1733 | 28 privilege.member_id = member.id |
bsw@1733 | 29 privilege.unit_id = unit_id |
bsw@1733 | 30 privilege.initiative_right = true |
bsw@1733 | 31 privilege.voting_right = true |
bsw@1733 | 32 privilege:save() |
bsw@1733 | 33 end |
bsw@1733 | 34 |
bsw@1733 | 35 verification.verified_member_id = member.id |
bsw@1733 | 36 |
bsw@1733 | 37 verification.comment = (verification.comment or "").. " /// Account created" |
bsw@1733 | 38 |
bsw@1733 | 39 verification:save() |
bsw@1733 | 40 |