public function updateMe(User $user, array $input, UpdateListenerInterface $listener) { $this->profileValidator->setCurrentIdFor('email', $user->id); if (!($valid = $this->profileValidator->isValid($input))) { return $listener->onUpdateFail($this->profileValidator->getMessages()); } if (!empty($input['password'])) { if (!$user->checkPassword($input['old_password'])) { return $listener->onUpdateFail([Lang::get("messages.old_password_incorrect")]); } } unset($input['old_password']); unset($input['password_confirmation']); try { $this->userRepo->update($user->id, $input); return $listener->onUpdateSuccess(Lang::get("messages.operation_success")); } catch (NotFoundException $e) { return $listener->onUpdateNotFound(); } catch (RepositoryException $e) { return $listener->onUpdateFail([Lang::get("messages.database_error")]); } }