public function validateIsProfileOwnedByAccount(Account $account, Profile $profile) : self { if (!$account->getProfiles()->contains($profile)) { throw new PermissionsDeniedException("You're not an owner of this profile"); } return $this; }
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 __invoke(Account $account) { $accountId = $account->getId(); $accountEmail = $account->getEmail(); $this->accountRepository->deleteAccount($account); return ['id' => $accountId, 'email' => $accountEmail, 'entity' => $account]; }
public function createProfileForAccount(Account $account) : Profile { if ($account->getProfiles()->count() >= self::MAX_PROFILES_PER_ACCOUNT) { throw new MaxProfilesReachedException(sprintf('You can only have %d profiles per account', self::MAX_PROFILES_PER_ACCOUNT)); } $account->getProfiles()->add($profile = new Profile($account)); $this->profileRepository->createProfile($profile); $this->accountService->switchToProfile($account, $profile->getId()); $this->generateProfileImage($profile->getId()); $this->backdropService->backdropPreset($profile, $this->backdropPresetFactory, $this->backdropPresetFactory->getListIds()[array_rand($this->backdropPresetFactory->getListIds())]); $this->getEventEmitter()->emit(self::EVENT_PROFILE_CREATED, [$profile]); return $profile; }
public function verifyPassword(Account $account, string $password) : bool { return password_verify($password, $account->getPassword()); }
public function auth(Account $account) : Account { $_SESSION[SessionStrategy::SESSION_API_KEY] = $account->getAPIKey(); $this->currentAccountService->signInWithAccount($account); return $account; }
public function equals(Account $compare) : bool { return $compare->getId() === $this->getId(); }
public function switchToProfile(Account $account, int $switchToProfileId) : Account { if (!$account->getProfiles()->filter(function (Profile $profile) use($switchToProfileId) { return $profile->getId() === $switchToProfileId; })->count()) { throw new AccountNotContainsProfileException(sprintf('Profile (ID: %s) is not exists', $switchToProfileId)); } $account->getProfiles()->map(function (Profile $profile) use($switchToProfileId, &$found) { $profile->getId() === $switchToProfileId ? $profile->setAsCurrent() : $profile->unsetAsCurrent(); }); $this->accountRepository->saveAccount($account); array_map(function (Profile $profile) { $this->profileRepository->saveProfile($profile); }, $account->getProfiles()->toArray()); return $account; }
public function toJSON() : array { return ['account' => $this->account->toJSON(), 'apps' => ['admin' => $this->appAdmin, 'reports' => $this->appReports, 'feedback' => $this->appFeedback]]; }