Last active
January 16, 2019 20:36
-
-
Save franksteinberg/99d0fc1ee14e47d74667d2c2c34bf49b to your computer and use it in GitHub Desktop.
VerifyJwtToken Middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
class VerifyJwtToken | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @param string|null $token | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next, $token = null) | |
{ | |
if (! JwtHelper::verify($token)) { | |
return response()->json([ | |
'error' => true, | |
'msg' => 'No valid token provided.', | |
'data' => [], | |
], 403); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment