Skip to content

Instantly share code, notes, and snippets.

@franksteinberg
Last active January 16, 2019 20:36
Show Gist options
  • Save franksteinberg/99d0fc1ee14e47d74667d2c2c34bf49b to your computer and use it in GitHub Desktop.
Save franksteinberg/99d0fc1ee14e47d74667d2c2c34bf49b to your computer and use it in GitHub Desktop.
VerifyJwtToken Middleware
<?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