You are here

class JwtAuthValidateEvent in JSON Web Token Authentication (JWT) 8.0

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

Class JwtAuthValidateEvent.

@package Drupal\jwt\Authentication\Event

Hierarchy

Expanded class hierarchy of JwtAuthValidateEvent

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

File

src/Authentication/Event/JwtAuthValidateEvent.php, line 10

Namespace

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

  /**
   * Variable tracking whether a token has been marked invalid.
   *
   * @var bool
   */
  protected $valid = TRUE;

  /**
   * Variable holding a reason that a token was marked invalid.
   *
   * @var string
   */
  protected $invalidReason;

  /**
   * Marks a token as invalid and stops further propagation of the event.
   *
   * This marks a given token as invalid. You should provide a reason for
   * invalidating the token. This message will not be kept private, so one
   * should be cautious of leaking secure information here.
   *
   * @param string $reason
   *   The reason that this token was invalidated.
   */
  public function invalidate($reason) {
    $this->valid = FALSE;
    $this->invalidReason = $reason;
    $this
      ->stopPropagation();
  }

  /**
   * Returns whether a token was considered valid.
   *
   * @return bool
   *   Returns if the token is valid.
   */
  public function isValid() {
    return $this->valid;
  }

  /**
   * Returns a string describing why a JWT was considered invalid.
   *
   * @return string
   *   The reason the token is invalid.
   */
  public function invalidReason() {
    return $this->invalidReason;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
JwtAuthBaseEvent::$jwt protected property The JsonWebToken.
JwtAuthBaseEvent::getToken public function Returns the JWT.
JwtAuthBaseEvent::__construct public function Constructs a JwtAuthEvent with a JsonWebToken. 1
JwtAuthValidateEvent::$invalidReason protected property Variable holding a reason that a token was marked invalid.
JwtAuthValidateEvent::$valid protected property Variable tracking whether a token has been marked invalid.
JwtAuthValidateEvent::invalidate public function Marks a token as invalid and stops further propagation of the event.
JwtAuthValidateEvent::invalidReason public function Returns a string describing why a JWT was considered invalid.
JwtAuthValidateEvent::isValid public function Returns whether a token was considered valid.