Files
faveo/app/Http/Middleware/JwtAuthenticate.php
Shift 87acc30a0b Apply Laravel coding style
Shift automatically applies the Laravel coding style - which uses the PSR-12 coding style as a base with some minor additions.

You may customize the code style applied by configuring [Pint](https://laravel.com/docs/pint), [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer), or [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for your project root.

For more information on customizing the code style applied by Shift, [watch this short video](https://laravelshift.com/videos/shift-code-style).
2023-01-07 20:32:31 +00:00

49 lines
1.1 KiB
PHP

<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Http\Middleware;
use Closure;
use Tymon\JWTAuth\Http\Middleware\BaseMiddleware;
/**
* Middleware to handle JWT Authentication for the API call which requires
* a valid token.
*
* @author Manish Verma <manish.verma@ladybirdweb.com>
*
* @since v1.10
*/
class JwtAuthenticate extends BaseMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
*/
public function handle($request, Closure $next)
{
try {
$this->authenticate($request);
return $next($request);
} catch (\Exception $e) {
return response(
['success' => false, 'message' => $e->getMessage()],
$e->getStatusCode()
);
}
}
}