bsw@1071: if util.is_profile_field_locked(app.session.member, "name") then bsw@286: error("access denied") bsw@286: end bsw@286: bsw@9: local name = param.get("name") bsw@9: bsw@9: name = util.trim(name) bsw@9: bsw@75: if #name < 3 then bsw@75: slot.put_into("error", _"This name is too short!") bsw@75: return false bsw@9: end bsw@9: bsw@9: app.session.member.name = name bsw@9: bsw@9: local db_error = app.session.member:try_save() bsw@9: bsw@9: if db_error then bsw@9: if db_error:is_kind_of("IntegrityConstraintViolation.UniqueViolation") then bsw@9: slot.put_into("error", _"This name is already taken, please choose another one!") bsw@9: return false bsw@9: end bsw@9: db_error:escalate() bsw@9: end bsw@9: bsw@9: slot.put_into("notice", _"Your name has been changed")