Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] fix: call to user on NULL on fresh login #324

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/Actions/AuthenticateOAuthCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function authenticate(string $provider, ProviderUser $providerAccount): R
$previousUrl = session()->get('socialstream.previous_url');

if (
class_exists(FortifyFeatures::class)
&& FortifyFeatures::enabled(FortifyFeatures::registration())
&& ! $account
class_exists(FortifyFeatures::class)
&& FortifyFeatures::enabled(FortifyFeatures::registration())
&& ! $account
&& ($previousUrl === route('register') || Features::hasCreateAccountOnFirstLoginFeatures())
) {
$user = Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->first();
Expand All @@ -66,12 +66,17 @@ class_exists(FortifyFeatures::class)
return $this->register($provider, $providerAccount);
}

if (! Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
return $this->redirectAuthFailed(
error: __('An account with this :Provider sign in was not found. Please register or try a different sign in method.', ['provider' => Providers::name($provider)])
);
if (! $account) {
if (! Features::hasCreateAccountOnFirstLoginFeatures()) {
return $this->redirectAuthFailed(
error: __('An account with this :Provider sign in was not found. Please register or try a different sign in method.', ['provider' => Providers::name($provider)])
);
}

return $this->register($provider, $providerAccount);
}


$user = $account->user;

$this->updatesConnectedAccounts->update($user, $account, $provider, $providerAccount);
Expand Down
Loading