1. Go to this page and download the library: Download ramosisw/cakephp-jwt-claims library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ramosisw / cakephp-jwt-claims example snippets
// In your controller, for e.g. src/Controller/AppController.php
public function initialize()
{
parent::initialize();
//Config JWT with ADmad Plugin for more info see https://github.com/ADmad/cakephp-jwt-auth
$this->loadComponent('Auth', [/*..*/]);
//Load Claims component
$this->loadComponent('RamosISW/Jwt.Claims',[
'claims_key' => 'data', //name where is claims on JWT Payload
//Wath claims be read
'data' => [
'user_id', 'user_email', 'user_name'
]
]);
}
public function index(){
//read user email sends on token
$this->log($this->Claims->user_email);
//set claims to use on view
$this->set('Claims', $this->Claims);
}