/** * Confirm user registration * @param Command\ConfirmCommand $command * @return void */ public function confirm(Command\ConfirmCommand $command) { $apiUser = $this->apiUserRepository->findUserByHash($command->hash); if (is_null($apiUser)) { throw new \RuntimeException('Can not confirm registration.'); } try { $apiUser->activate($command->hash); $this->apiUserRepository->store($apiUser); } catch (\Exception $e) { throw new \RuntimeException('Can not confirm registration.'); } }
/** * @param ChangePasswordCommand $command * @return void */ public function changePassword(ChangePasswordCommand $command) { /** * @var ApiUser $apiUser */ $apiUser = $this->apiUserRepository->findUserByHash($command->hash); if (is_null($apiUser)) { throw new \RuntimeException('Your password reset link has expired.'); } $apiUser->changePassword($command->password); $this->apiUserRepository->store($apiUser); }