/** * {@inheritdoc} */ public function create(UserInterface $user) { $payload = array('exp' => time() + $this->ttl); $this->addUserIdentityToPayload($user, $payload); $event = new JWTCreatedEvent($payload, $user, $this->request); $this->dispatcher->dispatch(Events::JWT_CREATED, $event); return $this->jwtEncoder->encode($event->getData()); }
/** * {@inheritdoc} */ public function create(UserInterface $user) { $payload = array(); if (is_numeric($this->ttl)) { $payload['exp'] = time() + $this->ttl; } $this->addUserIdentityToPayload($user, $payload); $jwtCreatedEvent = new JWTCreatedEvent($payload, $user, $this->request); $this->dispatcher->dispatch(Events::JWT_CREATED, $jwtCreatedEvent); $jwtString = $this->jwtEncoder->encode($jwtCreatedEvent->getData()); $jwtEncodedEvent = new JWTEncodedEvent($jwtString); $this->dispatcher->dispatch(Events::JWT_ENCODED, $jwtEncodedEvent); return $jwtString; }