liquid_feedback_frontend
annotate app/main/member/_action/update_name.lua @ 1513:895d327a3cb1
Limit issues to single unit if single unit mode is configured
| author | bsw | 
|---|---|
| date | Thu Aug 20 13:50:03 2020 +0200 (2020-08-20) | 
| parents | 32cc544d5a5b | 
| children | 
| rev | line source | 
|---|---|
| bsw@1071 | 1 if util.is_profile_field_locked(app.session.member, "name") then | 
| bsw/jbe@1309 | 2 return execute.view { module = "index", view = "403" } | 
| bsw@286 | 3 end | 
| bsw@286 | 4 | 
| bsw@9 | 5 local name = param.get("name") | 
| bsw@9 | 6 | 
| bsw@9 | 7 name = util.trim(name) | 
| bsw@9 | 8 | 
| bsw@75 | 9 if #name < 3 then | 
| bsw@75 | 10 slot.put_into("error", _"This name is too short!") | 
| bsw@75 | 11 return false | 
| bsw@9 | 12 end | 
| bsw@9 | 13 | 
| bsw@9 | 14 app.session.member.name = name | 
| bsw@9 | 15 | 
| bsw@9 | 16 local db_error = app.session.member:try_save() | 
| bsw@9 | 17 | 
| bsw@9 | 18 if db_error then | 
| bsw@9 | 19 if db_error:is_kind_of("IntegrityConstraintViolation.UniqueViolation") then | 
| bsw@9 | 20 slot.put_into("error", _"This name is already taken, please choose another one!") | 
| bsw@9 | 21 return false | 
| bsw@9 | 22 end | 
| bsw@9 | 23 db_error:escalate() | 
| bsw@9 | 24 end | 
| bsw@9 | 25 | 
| bsw@9 | 26 slot.put_into("notice", _"Your name has been changed") |