liquid_feedback_frontend
annotate app/main/member/_action/update_name.lua @ 1226:b79085a2f92e
Minor code cleanup in app/main/draft/diff.lua
| author | jbe | 
|---|---|
| date | Tue Dec 01 17:30:33 2015 +0100 (2015-12-01) | 
| parents | 58f48a8a202a | 
| children | 32cc544d5a5b | 
| rev | line source | 
|---|---|
| bsw@1071 | 1 if util.is_profile_field_locked(app.session.member, "name") then | 
| bsw@286 | 2 error("access denied") | 
| 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") |