|
|
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|
|
|
|
|
namespace App\Middleware\Auth;
|
|
|
|
|
|
+use App\Controller\Resource\ApiResource;
|
|
|
use App\Model\User;
|
|
|
use Hyperf\Di\Annotation\Inject;
|
|
|
use Phper666\JWTAuth\Exception\TokenValidException;
|
|
|
@@ -43,16 +44,16 @@ class TokenMiddleware implements MiddlewareInterface
|
|
|
if (strlen($token) > 0) {
|
|
|
$token = JWTUtil::handleToken($token);
|
|
|
if ($token == false || !$this->jwt->checkToken($token)) {
|
|
|
- throw new TokenValidException(__('api.1005'), 401);
|
|
|
+ return ApiResource::failed(1005);
|
|
|
}
|
|
|
|
|
|
$authId = $token->getClaim('authId');
|
|
|
$user = User::where('id', $authId)->where(['enable'=> 'T'])->first();
|
|
|
if(!$user){
|
|
|
- throw new TokenValidException(__('api.1029'), 401);
|
|
|
+ return ApiResource::failed(1029);
|
|
|
}
|
|
|
}else{
|
|
|
- throw new TokenValidException(__('api.1010'), 401);
|
|
|
+ return ApiResource::failed(1010);
|
|
|
}
|
|
|
|
|
|
} catch (\Exception $exception){
|