liquid_feedback_frontend
annotate app/main/member/_action/update_name.lua @ 286:c587d8762e62
Registration process updated for Core 2.0, lockable member fields, notification settings
author | bsw |
---|---|
date | Sat Feb 25 11:51:37 2012 +0100 (2012-02-25) |
parents | 733f65c0c0a0 |
children | 58f48a8a202a |
rev | line source |
---|---|
bsw@286 | 1 if config.locked_profile_fields.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") |