php - Laravel Refreshing JWT tokens -


i have small lumen / laravel app used api. able sign in , set jwt tokens after period of time timeout, expecting them refresh each time endpoint hit.

i've been looking @ docs tymon's jwt-auth cannot seem work.

below example of 1 of end points return array of users in db. when token timesout endpoint returns error you don't have previleges view users

i'd grateful if able advise me or show me how make code refresh token when hitting endpoint.

inside controller

public function index(request $request) {     $user = jwtauth::parsetoken()->authenticate();     if (!$user->isadmin()) {         return $this->error_respond(['error' => "you don't have previleges view users"]);     }     $users = $this->repository->findallwithplan();      return $this->respond(['users' => $users]); } 

inside routes.php

$app->group(['middleware' => 'jwt.auth'], function ($app) {     /**      * show users      */      $app->get(          'users',           [              'as' => 'user.all',               'middleware' => 'cors',               'uses' => 'app\http\controllers\usercontroller@index'          ]      ); }); 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -