public function JwtAuthConsumerSubscriber::loadUser in JSON Web Token Authentication (JWT) 8.0
Same name and namespace in other branches
- 8 modules/jwt_auth_consumer/src/EventSubscriber/JwtAuthConsumerSubscriber.php \Drupal\jwt_auth_consumer\EventSubscriber\JwtAuthConsumerSubscriber::loadUser()
Load and set a Drupal user to be authentication based on the JWT's uid.
Parameters
\Drupal\jwt\Authentication\Event\JwtAuthValidEvent $event: A JwtAuth event.
File
- modules/
jwt_auth_consumer/ src/ EventSubscriber/ JwtAuthConsumerSubscriber.php, line 72
Class
- JwtAuthConsumerSubscriber
- Class JwtAuthConsumerSubscriber.
Namespace
Drupal\jwt_auth_consumer\EventSubscriberCode
public function loadUser(JwtAuthValidEvent $event) {
$token = $event
->getToken();
$user_storage = $this->entityManager
->getStorage('user');
$uid = $token
->getClaim([
'drupal',
'uid',
]);
$user = $user_storage
->load($uid);
$event
->setUser($user);
}