From 28538fcadc93c7e6d958ca5a12c68174678d9f43 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 7 Oct 2021 20:30:24 +0200 Subject: [PATCH] wip #4765 @0.5 --- composer.json | 3 ++- src/CubistSocialiteAuthProvider.php | 31 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/CubistSocialiteAuthProvider.php diff --git a/composer.json b/composer.json index bf7de39..06061f9 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "extra": { "laravel": { "providers": [ - "Cubist\\Socialite\\CubistSocialiteServiceProvider" + "Cubist\\Socialite\\CubistSocialiteServiceProvider", + "Cubist\\Socialite\\CubistSocialiteAuthServiceProvider", ] } } diff --git a/src/CubistSocialiteAuthProvider.php b/src/CubistSocialiteAuthProvider.php new file mode 100644 index 0000000..56d51cf --- /dev/null +++ b/src/CubistSocialiteAuthProvider.php @@ -0,0 +1,31 @@ +registerPolicies(); + + Auth::viaRequest('socialitegoogle', function (Request $request) { + $socialiteUser = Socialite::driver('google')->user(); + if ($socialiteUser) { + $userClass = config('auth.providers.users.model'); + $instance = new $userClass(); + $instance->id = $socialiteUser->getId(); + $instance->email = $socialiteUser->getEmail(); + } + }); + } +} \ No newline at end of file -- 2.39.5