コード例 #1
0
 /**
  * @param JWTCreatedEvent $event
  *
  * @return void
  */
 public function onJWTCreated(JWTCreatedEvent $event)
 {
     if (!($request = $event->getRequest())) {
         return;
     }
     /** @var Traeger $traeger */
     $traeger = $event->getUser();
     $payload = $event->getData();
     $payload['traeger'] = array();
     $payload['traeger']['titel'] = $traeger->getTitel();
     $event->setData($payload);
 }
コード例 #2
0
 /**
  * Adds security info to the signed token
  *
  * @param JWTCreatedEvent $event
  * @return void
  */
 public function onJWTCreated(JWTCreatedEvent $event)
 {
     if (!($request = $event->getRequest())) {
         return;
     }
     /**
      * @var AuthUser $user
      */
     $user = $event->getUser();
     if (!$user->getIsActive()) {
         throw new AccessDeniedException('User is not active');
     }
     $databases = array();
     foreach ($user->getDatabases() as $database) {
         $databases[] = $database->getName();
     }
     $payload = $event->getData();
     $payload['ip'] = $request->getClientIp();
     $payload['databases'] = $databases;
     $event->setData($payload);
 }