public function clearTwoFactorAuthentication(AccountInterface $account) { $account->setTwoFactorAuthenticationType(null); $account->setTwoFactorAuthenticationCode(null); $this->entityManager->persist($account); $this->entityManager->flush($account); }
public function changePassword(AccountInterface $account, $newPassword) { $credential = $this->crypter->create($newPassword); $account->setCredential($credential); $this->entityManager->persist($account); $this->entityManager->flush($account); }
public function getForAccount(AccountInterface $account) { $repository = $this->entityManager->getRepository(SessionEntity::class); $qb = $repository->createQueryBuilder('s'); $qb->select('s'); $qb->where($qb->expr()->eq('s.account', ':account')); $qb->orderBy('s.lastModified', 'DESC'); $qb->setParameter(':account', $account->getId()->getBytes()); return $qb->getQuery()->getArrayResult(); }
private function createAccountRole(AccountInterface $account) { $role = new Role('account-' . $account->getId()->toString()); /** @var Group $group */ foreach ($account->getGroups() as $group) { foreach ($group->getPermissions() as $permission) { $role->addPermission($permission); } } return $role; }
public function getAccountDashboard(AccountInterface $account) { $dashboard = null; $dashboardId = $account->getProperty('dashboard'); if ($dashboardId) { $repository = $this->entityManager->getRepository(DashboardEntity::class); $dashboard = $repository->find($dashboardId); } if (!$dashboard) { $dashboard = new DashboardEntity('Dashboard ' . $account->getContact()->getDisplayName()); $account->setProperty('dashboard', $dashboard->getId()->toString()); $this->entityManager->persist($dashboard); $this->entityManager->flush(); } return $dashboard; }
public function makePrimary(AccountInterface $account, $id) { $emailAddressesRepository = $this->entityManager->getRepository(EmailEntity::class); $qb = $emailAddressesRepository->createQueryBuilder('e'); $qb->update(); $qb->set('e.isPrimary', ':isPrimary'); $qb->where($qb->expr()->eq('e.account', ':account')); $qb->setParameter(':isPrimary', false); $qb->setParameter(':account', $account->getId()->getBytes()); $qb->getQuery()->execute(); $emailAddress = $this->getAddress($account, $id); $emailAddress->setIsPrimary(true); $this->entityManager->persist($emailAddress); $this->entityManager->flush($emailAddress); return $emailAddress; }
private function redirectAfterLogin(AccountInterface $account) { if (!$this->authSession->verified && $account->hasTwoFactorAuthentication()) { return $this->redirect()->toRoute('login-tfa'); } $this->authenticationService->getStorage()->write($this->authSession->identity); $this->resetTwoFactorAuthentication(); if ($this->authSession->url) { $url = $this->authSession->url; unset($this->authSession->url); return $this->redirect()->toUrl($url); } return $this->redirect()->toRoute('dashboard'); }