Skip to content

Commit

Permalink
[6.x] Bind stateful guard if fortify is not installed (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbutcher authored Jul 19, 2024
1 parent d478d32 commit 8e33d60
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
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

0 comments on commit 8e33d60

Please sign in to comment.