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

[6.x] Bind stateful guard if fortify is not installed #362

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions config/filament.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use JoelButcher\Socialstream\Providers;

return [
'guard' => 'web', // used if Fortify is not installed
'middleware' => ['web'],
'prompt' => 'Or Login Via',
'providers' => [
Expand Down
1 change: 1 addition & 0 deletions config/socialstream.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use JoelButcher\Socialstream\Providers;

return [
'guard' => 'web', // used if Fortify is not installed
'middleware' => ['web'],
'prompt' => 'Or Login Via',
'providers' => [
Expand Down
10 changes: 9 additions & 1 deletion src/SocialstreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace JoelButcher\Socialstream;

use Illuminate\Contracts\Auth\StatefulGuard;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
Expand Down Expand Up @@ -33,7 +35,6 @@
use JoelButcher\Socialstream\Resolvers\OAuth\LinkedInOAuth2RefreshResolver;
use JoelButcher\Socialstream\Resolvers\OAuth\SlackOAuth2RefreshResolver;
use JoelButcher\Socialstream\Resolvers\OAuth\TwitterOAuth2RefreshResolver;
use Laravel\Fortify\Fortify;
use Laravel\Jetstream\Jetstream;
use Livewire\Livewire;

Expand All @@ -49,6 +50,13 @@ public function register(): void
$this->mergeConfigFrom(__DIR__.'/../config/socialstream.php', 'socialstream');

$this->registerResponseBindings();

// if there's no fortify, we need to bind a stateful guard to the container
if (! config('fortify.guard')) {
$this->app->bind(StatefulGuard::class, function () {
return Auth::guard(config('socialstream.guard'));
});
}
}

/**
Expand Down
Loading