DutchCodingCompany / filament-socialite

Add OAuth login through Laravel Socialite to Filament.
MIT License
153 stars 38 forks source link

Error when setCreateUserCallback is called #25

Closed jigzstar closed 1 year ago

jigzstar commented 1 year ago

Using the code from the documentation, I am getting the following error:

App\Providers\AppServiceProvider::App\Providers\{closure}(): Argument #2 ($socialite) must be of type DutchCodingCompany\FilamentSocialite\Facades\FilamentSocialite, DutchCodingCompany\FilamentSocialite\FilamentSocialite given,

Code in AppServiceProvider.php boot method

use Laravel\Socialite\Contracts\User as UserContract;
use DutchCodingCompany\FilamentSocialite\Facades\FilamentSocialite;
...

        FilamentSocialite::setCreateUserCallback(fn (UserContract $oauthUser, \DutchCodingCompany\FilamentSocialite\Facades\FilamentSocialite $socialite) => $socialite->getUserModelClass()::create([
            'name' => $oauthUser->getName(),
            'password' => Str::random(32),
            'email' => $oauthUser->getEmail(),
        ]));
jigzstar commented 1 year ago

Using the code from the documentation, I am getting the following error:

App\Providers\AppServiceProvider::App\Providers\{closure}(): Argument #2 ($socialite) must be of type DutchCodingCompany\FilamentSocialite\Facades\FilamentSocialite, DutchCodingCompany\FilamentSocialite\FilamentSocialite given,

Code in AppServiceProvider.php boot method

use Laravel\Socialite\Contracts\User as UserContract;
use DutchCodingCompany\FilamentSocialite\Facades\FilamentSocialite;
...

        FilamentSocialite::setCreateUserCallback(fn (UserContract $oauthUser, \DutchCodingCompany\FilamentSocialite\Facades\FilamentSocialite $socialite) => $socialite->getUserModelClass()::create([
            'name' => $oauthUser->getName(),
            'password' => Str::random(32),
            'email' => $oauthUser->getEmail(),
        ]));

I'm so dumb, Nevermind, but for anyone else:

FilamentSocialite::setCreateUserCallback(fn (UserContract $oauthUser) => \App\Models\User::create([
'name' => $oauthUser->getName(),
'password' => Str::random(32),
'email' => $oauthUser->getEmail(),
]));