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
Post a Comment