PHP code example of fatihozpolat / jwtvalidity

1. Go to this page and download the library: Download fatihozpolat/jwtvalidity 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/ */

    

fatihozpolat / jwtvalidity example snippets


'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class,

'storage' => FatihOzpolat\JWTValidity\Repository\JwtBlockedStorageRepository::class,

use FatihOzpolat\JWTValidity\User as FOUser;
...
...

class User extends FOUser
{
  ...

use FatihOzpolat\JWTValidity\Manager;
...
...

//login
if($token = auth()->attempt($credentials)){
  Manager::addToken($token);
  ...
  ...



//logout
$authHeader = request()->header('authorization');
$token = substr($authHeader, 7); //remove Bearer
Manager::removeToken($token);  

$user = User::find(1);
$res = Manager::blockTokens($user); //true or false