|
@@ -4,8 +4,6 @@ namespace App\Providers;
|
|
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
-use Tymon\JWTAuth\Exceptions\TokenExpiredException;
|
|
|
-use Tymon\JWTAuth\Exceptions\TokenInvalidException;
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
{
|
|
@@ -19,41 +17,5 @@ class AppServiceProvider extends ServiceProvider
|
|
|
Validator::extend('mobile', function ($attribute, $value, $parameters) {
|
|
|
return preg_match('/^1[3456789]{1}\d{9}$/', $value);
|
|
|
});
|
|
|
- app('Dingo\Api\Exception\Handler')->register(function (\Tymon\JWTAuth\Exceptions\JWTException $e) {
|
|
|
-
|
|
|
- if ($e instanceof TokenExpiredException) {
|
|
|
-
|
|
|
- $error = [
|
|
|
- 'message' => 'Token Expired',
|
|
|
- 'errors' => [
|
|
|
- 'token_expired' => 'token_expired'
|
|
|
- ],
|
|
|
- 'code' => $e->getStatusCode(),
|
|
|
- 'status_code' => $e->getStatusCode(),
|
|
|
- ];
|
|
|
-
|
|
|
- } else if ($e instanceof TokenInvalidException) {
|
|
|
-
|
|
|
- $error = [
|
|
|
- 'message' => 'Token Invalid',
|
|
|
- 'errors' => [
|
|
|
- 'token_invalid' => 'token_invalid'
|
|
|
- ],
|
|
|
- 'code' => $e->getStatusCode(),
|
|
|
- 'status_code' => $e->getStatusCode(),
|
|
|
- ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return response()->json($error, $e->getStatusCode());
|
|
|
- });
|
|
|
-
|
|
|
- app('Dingo\Api\Exception\Handler')->register(function (\Illuminate\Auth\AuthenticationException $e) {
|
|
|
- $error = [
|
|
|
- 'message' => '请重新登录',
|
|
|
- 'code' => '1001',
|
|
|
- ];
|
|
|
- return response()->json($error);
|
|
|
- });
|
|
|
}
|
|
|
}
|