diff --git a/app/Infrastructure/Http/Controllers/GoogleController.php b/app/Infrastructure/Http/Controllers/GoogleController.php index 6f15e8d..b5e2618 100644 --- a/app/Infrastructure/Http/Controllers/GoogleController.php +++ b/app/Infrastructure/Http/Controllers/GoogleController.php @@ -5,7 +5,9 @@ declare(strict_types=1); namespace Toby\Infrastructure\Http\Controllers; use Illuminate\Contracts\Auth\Factory as AuthFactory; +use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Support\Str; use Laravel\Socialite\SocialiteManager; use Symfony\Component\HttpFoundation\RedirectResponse; use Toby\Eloquent\Models\User; @@ -17,7 +19,7 @@ class GoogleController extends Controller return $socialiteManager->driver("google")->redirect(); } - public function callback(AuthFactory $auth, SocialiteManager $socialiteManager): RedirectResponse + public function callback(AuthFactory $auth, SocialiteManager $socialiteManager, Hasher $hash): RedirectResponse { $socialUser = $socialiteManager->driver("google")->user(); @@ -34,6 +36,7 @@ class GoogleController extends Controller ]); } + $user->update(["password" => $hash->make(Str::random(40))]); $auth->guard()->login($user, true); return redirect()->route("dashboard"); diff --git a/database/migrations/2022_03_21_135927_add_password_column_in_users_table.php b/database/migrations/2022_03_21_135927_add_password_column_in_users_table.php new file mode 100644 index 0000000..7dbd238 --- /dev/null +++ b/database/migrations/2022_03_21_135927_add_password_column_in_users_table.php @@ -0,0 +1,23 @@ +string("password")->nullable(); + }); + } + + public function down(): void + { + Schema::table("users", function (Blueprint $table): void { + $table->dropColumn("password"); + }); + } +};