diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 697f930..7e9a193 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -189,7 +189,8 @@ class AuthController extends Controller */ public function logout(Request $request) { - $token = $request->getCurrentToken(); + $token = $request->bearerToken(); + if (blank($token)) { return new JsonResponse([ 'message' => 'Not authorized request.', @@ -216,7 +217,7 @@ class AuthController extends Controller public function revoke(string $token) { /** @var Fingerprint $token */ - $token = Auth::user()->fingerprints()->firstWhere([ + $token = Fingerprint::firstWhere([ 'token' => $token, ]); diff --git a/config/services.php b/config/services.php index 95b9b0a..5c0ae34 100644 --- a/config/services.php +++ b/config/services.php @@ -16,6 +16,6 @@ return [ 'google' => [ 'client_id' => '1002439248397-oa6hnh25n6qri3q4kst62gvb1k9ki65l.apps.googleusercontent.com', 'client_secret' => 'tKbiyh5hOjYIcj-W1y3N8X5R', - 'redirect' => 'http://localhost:8000/user/v1/auth/google/callback', + 'redirect' => env('APP_URL').'/user/v1/auth/google/callback', ], ]; diff --git a/routes/api.php b/routes/api.php index 7e8d9c9..a51789c 100644 --- a/routes/api.php +++ b/routes/api.php @@ -14,11 +14,11 @@ $router->get('/callback', 'CreditController@callback'); $router->get('/{transaction}/redirection', 'CreditController@redirection'); $router->group(['prefix' => 'auth'], function () use ($router) { - $router->get('/', 'AuthController@auth'); + $router->get('/', 'AuthController@auth')->middleware('auth:api'); $router->delete('/', 'AuthController@delete'); $router->get('/info', 'AuthController@authWithInfo'); $router->post('login', 'AuthController@login'); - $router->post('logout', 'AuthController@logout'); + $router->post('logout', 'AuthController@logout')->middleware('auth:api'); $router->post('register', 'AuthController@register'); $router->post('revoke/{token}', 'AuthController@revoke'); @@ -27,8 +27,8 @@ $router->group(['prefix' => 'auth'], function () use ($router) { $router->post('verification', 'AuthController@verification'); - $router->get('google/redirect', 'AuthController@redirectToGoogle'); - $router->get('google/callback', 'AuthController@handleGoogleCallback'); + $router->get('google/redirect', 'AuthController@redirectToGoogle')->name('google.redirect'); + $router->get('google/callback', 'AuthController@handleGoogleCallback')->name('google.callback'); }); $router->group(['prefix' => 'businesses', 'middleware' => 'auth:api'], function () use ($router) {