You are here

class JwtAuthValidEvent in JSON Web Token Authentication (JWT) 8

Same name and namespace in other branches
  1. 8.0 src/Authentication/Event/JwtAuthValidEvent.php \Drupal\jwt\Authentication\Event\JwtAuthValidEvent

Class JwtAuthValidEvent.

@package Drupal\jwt\Authentication\Provider

Hierarchy

Expanded class hierarchy of JwtAuthValidEvent

2 files declare their use of JwtAuthValidEvent
JwtAuth.php in src/Authentication/Provider/JwtAuth.php
JwtAuthConsumerSubscriber.php in modules/jwt_auth_consumer/src/EventSubscriber/JwtAuthConsumerSubscriber.php

File

src/Authentication/Event/JwtAuthValidEvent.php, line 14

Namespace

Drupal\jwt\Authentication\Event
View source
class JwtAuthValidEvent extends JwtAuthBaseEvent {

  /**
   * Variable holding the user authenticated by the token in the payload.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $user;

  /**
   * {@inheritdoc}
   */
  public function __construct(JsonWebTokenInterface $token) {
    $this->user = User::getAnonymousUser();
    parent::__construct($token);
  }

  /**
   * Sets the authenticated user that will be used for this request.
   *
   * @param \Drupal\user\UserInterface $user
   *   A loaded user object.
   */
  public function setUser(UserInterface $user) {
    $this->user = $user;
  }

  /**
   * Returns a loaded user to use if the token is validated.
   *
   * @return \Drupal\user\UserInterface
   *   A loaded user object
   */
  public function getUser() {
    return $this->user;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
JwtAuthBaseEvent::$jwt protected property The JsonWebToken.
JwtAuthBaseEvent::getToken public function Returns the JWT.
JwtAuthValidEvent::$user protected property Variable holding the user authenticated by the token in the payload.
JwtAuthValidEvent::getUser public function Returns a loaded user to use if the token is validated.
JwtAuthValidEvent::setUser public function Sets the authenticated user that will be used for this request.
JwtAuthValidEvent::__construct public function Constructs a JwtAuthEvent with a JsonWebToken. Overrides JwtAuthBaseEvent::__construct