You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
535 B
28 lines
535 B
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
|
|
class JWTAuthorize
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next, $guard)
|
|
{
|
|
if (!auth()->guard($guard)->user()) {
|
|
return response()->json([
|
|
'errorcode' => '401',
|
|
'errormsg' => '鉴权失败'
|
|
], 401);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|