public function format(Account $account, array $frontline) { $profiles = array_map(function (Profile $profile) { return $this->profileFormatter->format($profile); }, $account->getProfiles()->toArray()); return ["api_key" => $account->getAPIKey(), "account" => $account->toJSON(), "profiles" => $profiles, "frontline" => $frontline]; }
public function createAccount($email, $password = null) : Account { $account = new Account(); $account->setEmail($email)->setPassword($this->passwordVerifyService->generatePassword($password)); while ($this->checkAPIKeyCollision($account->getAPIKey())) { $account->regenerateAPIKey(); } $this->accountRepository->createAccount($account); $this->getEventEmitter()->emit(self::EVENT_ACCOUNT_CREATED, [$account]); $this->profileService->createProfileForAccount($account); $this->accountRepository->saveAccount($account); return $account; }
public function auth(Account $account) : Account { $_SESSION[SessionStrategy::SESSION_API_KEY] = $account->getAPIKey(); $this->currentAccountService->signInWithAccount($account); return $account; }