Skip to content

Commit

Permalink
just want to see if I can get Google Oauth setup for integration into…
Browse files Browse the repository at this point in the history
… those tools
  • Loading branch information
alnutile committed Jul 13, 2024
1 parent 85bf617 commit d248f52
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/GoogleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Laravel\Socialite\Facades\Socialite;

Expand Down Expand Up @@ -41,13 +40,15 @@ public function handleGoogleCallback()
// Here you would typically save the user info and tokens to your database

request()->session()->flash('flash.bannerStyle', 'Google Authentication Successful!');

return to_route('collections.index');
} catch (\Exception $e) {
Log::error('Error authenticating with Google', [
'error' => $e->getMessage(),
]);
request()->session()->flash('flash.bannerStyle', 'danger');
request()->session()->flash('flash.banner', 'Google Authentication Failed');

return to_route('collections.index');
}
}
Expand Down
2 changes: 1 addition & 1 deletion config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'),
'client_secret' => env('GOOGLE_CLIENT_SECRET'),
'redirect' => 'https://dailyai.sharedwithexpose.com' . '/auth/google/callback',
'redirect' => 'https://dailyai.sharedwithexpose.com'.'/auth/google/callback',
],

];
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ parameters:
- vendor
- app/Actions/*
- app/Http/Resources/*
- app/Http/Controllers/GoogleController.php

checkMissingIterableValueType: false
treatPhpDocTypesAsCertain: false
5 changes: 2 additions & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@
'verified',
])->group(function () {


Route::get('/auth/google', [\App\Http\Controllers\GoogleController::class, 'redirectToGoogle'])
->name('auth.google');
->name('auth.google');
Route::get('/auth/google/callback', [\App\Http\Controllers\GoogleController::class, 'handleGoogleCallback'])
->name('auth.google.callback');
->name('auth.google.callback');

Route::controller(\App\Http\Controllers\DocumentController::class)->group(
function () {
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Http/Controllers/GoogleControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GoogleControllerTest extends TestCase
public function test_saves_meta_data(): void
{
$user = User::factory()->create([
'meta_data' => []
'meta_data' => [],
]);

Socialite::shouldReceive('driver->user')
Expand All @@ -27,7 +27,6 @@ public function test_saves_meta_data(): void
'getEmail' => '[email protected]',
]);


$this->actingAs($user)->get(route('auth.google.callback'));

$this->assertNotNull($user->refresh()->meta_data);
Expand Down

0 comments on commit d248f52

Please sign in to comment.