コード例 #1
0
 public function get($id)
 {
     $notification = $this->handler->get($id);
     if ($notification->getPerson()->getId() !== $this->person->getId()) {
         throw new AccessDeniedHttpException();
     }
     return $this->handler->get($id);
 }
コード例 #2
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();
 }
コード例 #3
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];
 }
コード例 #4
0
 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;
 }
コード例 #5
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);
 }