Ejemplo n.º 1
0
 public function findLoginsByPerson(PersonInterface $person, $limit = null)
 {
     $query = $this->createQueryBuilder('l')->where('l.userId = :person_id')->setParameter('person_id', $person->getId())->orderBy('l.createdAt', 'DESC');
     if ($limit > 0) {
         $query->setMaxResults($limit);
     }
     return $query->getQuery()->getResult();
 }
 public function get($id)
 {
     $notification = $this->handler->get($id);
     if ($notification->getPerson()->getId() !== $this->person->getId()) {
         throw new AccessDeniedHttpException();
     }
     return $this->handler->get($id);
 }
Ejemplo n.º 3
0
 public function getTargetPersonLevel(PersonInterface $person)
 {
     $roles = $person->getRoles();
     $level = 0;
     foreach ($this->getRoleMapping() as $role => $lvl) {
         if (in_array($role, $roles)) {
             $level = $lvl;
             break;
         }
     }
     return $level;
 }
Ejemplo n.º 4
0
 public function getTargetPersonLevel(PersonInterface $person)
 {
     $roles = $person->getRoles();
     $level = 0;
     if (in_array('ROLE_SUPER_ADMIN', $roles)) {
         $level = self::ROLE_SUPER_ADMIN;
     } elseif (in_array('ROLE_ADMIN', $roles)) {
         $level = self::ROLE_ADMIN;
     } elseif (in_array('ROLE_SUPER', $roles)) {
         $level = self::ROLE_SUPER_USER;
     } elseif (in_array('ROLE_DEV', $roles)) {
         $level = self::ROLE_DEV;
     } elseif (in_array('ROLE_USER', $roles)) {
         $level = self::ROLE_USER;
     }
     return $level;
 }
 public static function populateCountryStateCity(PersonInterface $person, FormInterface $form)
 {
     $country = $person->getCountry();
     $state = $person->getState();
     $city = $person->getCity();
     $countryName = '';
     if ($country) {
         $countryName = $country->getName();
     }
     $form->add('country', 'text', array('required' => true, 'mapped' => false, 'read_only' => true, 'data' => $countryName));
     $stateName = '';
     if ($state) {
         $stateName = $state->getName();
     }
     $form->add('state', 'text', array('required' => true, 'read_only' => 'true', 'mapped' => false, 'read_only' => true, 'data' => $stateName));
     $cityName = '';
     if ($city) {
         $cityName = $city->getName();
     }
     $form->add('city', 'text', array('required' => true, 'read_only' => 'true', 'mapped' => false, 'read_only' => true, 'data' => $cityName));
     return $form;
 }
Ejemplo n.º 6
0
 public function getAuthenticatedHandler(PersonInterface $person)
 {
     $id = $person->getId();
     if (!array_key_exists($id, $this->authenticatedHandlers)) {
         $this->authenticatedHandlers[$id] = new AuthenticatedNotificationHandler($person, $this);
     }
     return $this->authenticatedHandlers[$id];
 }
 protected function validateNotificationCore(ClientInterface $sender, PersonInterface $person, Request $request)
 {
     $notificationPerson = (int) $request->get('person');
     $notificationClient = (int) $request->get('sender');
     if ($notificationClient !== $sender->getId()) {
         throw new AccessDeniedHttpException("This application cannot impersonate other applications when sending notifications.");
     }
     if ($person->getId() !== $notificationPerson) {
         throw new AccessDeniedHttpException("You don't have permission to send notifications to this person.");
     }
     $scopes = $this->getClientScope($person, $sender);
     if (!is_array($scopes) || array_search('notifications', $scopes) === false) {
         throw new AccessDeniedHttpException("This person didn't allow you to send notifications.");
     }
     $categories = $this->getDoctrine()->getRepository('PROCERGSLoginCidadaoNotificationBundle:Category');
     $notificationCategory = $categories->find($request->get('category'));
     if ($notificationCategory->getClient()->getId() !== $sender->getId()) {
         throw new AccessDeniedHttpException("Invalid category.");
     }
     return true;
 }
 protected function removeBackupCodes(EntityManager $em, PersonInterface $person)
 {
     $backupCodes = $person->getBackupCodes();
     foreach ($backupCodes as $backupCode) {
         $em->remove($backupCode);
     }
 }
Ejemplo n.º 9
0
 public function registerLogin(Request $request, PersonInterface $person, array $controllerAction)
 {
     $auditUsername = $this->auditConfig->getCurrentUsername();
     $actionType = ActionLog::TYPE_LOGIN;
     $log = $this->initLog($request, $actionType, $controllerAction, $auditUsername);
     $log->setUserId($person->getId());
     $this->em->persist($log);
     $this->em->flush($log);
 }