Skip to content

Commit 9bb99bd

Browse files
authored
查询用户失败 返回401
1 parent 56a3912 commit 9bb99bd

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/Middleware/Jwt.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ public function handle($request, \Closure $next, $store = 'admin')
2929

3030
if (true === $this->app->jwt->store($store)->verify()) {
3131

32-
$jwt_user = $this->app['jwt.user'];
33-
34-
if ($jwt_user->bind()) {
35-
$user = $jwt_user->get();
32+
$user = $this->app['jwt.user'];
33+
34+
if ($user->bind()) {
35+
$info = $user->get();
36+
if (!$info){
37+
throw new JWTException('没有此用户', 401);
38+
}
39+
3640
// 路由注入
37-
$request->user = $user;
38-
41+
$request->user = $info;
42+
3943
// 绑定当前用户模型
40-
$model = $jwt_user->getClass();
41-
$this->app->bind($model, $user);
44+
$model = $info->getClass();
45+
$this->app->bind($model, $info);
4246
}
4347

4448
return $next($request);

0 commit comments

Comments
 (0)