12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- 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
- {
- /**
- * Register any application services.
- *
- * @return void
- */
- public function register()
- {
- 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);
- // });
- }
- }
|