51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
|
// +----------------------------------------------------------------------
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\middleware;
|
|
|
|
use think\App;
|
|
use think\Response;
|
|
|
|
class Check{
|
|
protected $app;
|
|
|
|
public function __construct(App $app){
|
|
$this->app = $app;
|
|
}
|
|
|
|
/**
|
|
* @title 处理请求
|
|
*
|
|
* @param [type] $request
|
|
* @param \Closure $next
|
|
* @param [type] $store
|
|
* @return void
|
|
*/
|
|
public function handle($request, \Closure $next, $store = null){
|
|
try {
|
|
$verify = \leruge\facade\JWT::validate();;
|
|
if (true === $verify) {
|
|
$user = \leruge\facade\JWT::auth();
|
|
if ($user->uid) {
|
|
// 路由注入
|
|
$request->user = $user;
|
|
}
|
|
return $next($request);
|
|
}
|
|
} catch (\think\Exception $e) {
|
|
return Response::create(['message' => $e->getMessage(), 'code' => 2000], 'json', 401);
|
|
}
|
|
}
|
|
|
|
public function bindUserAfter(){
|
|
|
|
}
|
|
}
|