From 95b899843b4a5d3a03333b7feceb67002e0f3ddc Mon Sep 17 00:00:00 2001 From: mahdihty Date: Tue, 2 Mar 2021 19:01:30 +0330 Subject: [PATCH] fix AuthServiceProvider.php --- app/Providers/AuthServiceProvider.php | 3 ++- routes/api.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 7936e8d..c02d1b6 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -30,7 +30,8 @@ class AuthServiceProvider extends ServiceProvider $this->app['request']->mixin(new RequestMixin); $this->app['request']->mixin(new BusinessInfoRequestMixin); - $this->app['auth']->viaRequest('api', function ($request) { + $this->app['auth']->viaRequest('token', function ($request) { + if ($request->bearerToken() === null) { return null; } diff --git a/routes/api.php b/routes/api.php index aa1192e..7e8d9c9 100644 --- a/routes/api.php +++ b/routes/api.php @@ -31,7 +31,7 @@ $router->group(['prefix' => 'auth'], function () use ($router) { $router->get('google/callback', 'AuthController@handleGoogleCallback'); }); -$router->group(['prefix' => 'businesses'], function () use ($router) { +$router->group(['prefix' => 'businesses', 'middleware' => 'auth:api'], function () use ($router) { $router->get('/', 'BusinessController@index'); $router->post('/', 'BusinessController@store');