diff --git a/.gitattributes b/.gitattributes
index f9347ec9..b4e207e7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,6 +7,7 @@
*.php diff=php
/.github export-ignore
+/workbench export-ignore
/tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
diff --git a/composer.json b/composer.json
index 2a674dc8..7289d977 100644
--- a/composer.json
+++ b/composer.json
@@ -20,6 +20,7 @@
],
"require": {
"php": "^8.1",
+ "illuminate/contracts": "^10",
"laravel/prompts": "^0.1.10",
"laravel/socialite": "^5.9",
"webmozart/assert": "^1.11"
@@ -28,6 +29,7 @@
"laravel/breeze": "^1.25",
"laravel/jetstream": "^4.0",
"laravel/sanctum": "^3.3",
+ "livewire/livewire": "^3",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
@@ -53,7 +55,8 @@
"stubs/breeze/default/app/",
"stubs/breeze/inertia-common/app/",
"stubs/jetstream/app/",
- "stubs/filament/app/"
+ "stubs/filament/app/",
+ "workbench/app/"
]
}
},
diff --git a/resources/filament/views/components/input-error.blade.php b/resources/filament/views/components/input-error.blade.php
index ad95f6b5..3c44bf17 100644
--- a/resources/filament/views/components/input-error.blade.php
+++ b/resources/filament/views/components/input-error.blade.php
@@ -1,7 +1,7 @@
@props(['messages'])
@if ($messages)
-
merge(['class' => 'text-sm text-red-600 dark:text-red-400 space-y-1']) }}>
+ merge(['class' => 'text-sm text-danger-600 dark:text-danger-400 space-y-1']) }}>
@foreach ((array) $messages as $message)
- {{ $message }}
@endforeach
diff --git a/src/Actions/Auth/Breeze/Blade/AuthenticateOAuthCallback.php b/src/Actions/Auth/Breeze/Blade/AuthenticateOAuthCallback.php
deleted file mode 100644
index aa662a72..00000000
--- a/src/Actions/Auth/Breeze/Blade/AuthenticateOAuthCallback.php
+++ /dev/null
@@ -1,181 +0,0 @@
-getId());
-
- // Authenticated...
- if (! is_null($user = auth()->user())) {
- return $this->alreadyAuthenticated($user, $account, $provider, $providerAccount);
- }
-
- // Registration...
- $previousUrl = session()->get('socialstream.previous_url');
-
- if (
- $previousUrl === route('register') ||
- (Features::hasCreateAccountOnFirstLoginFeatures() && $previousUrl === route('login'))
- ) {
- $user = Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->first();
-
- if ($user) {
- return $this->alreadyRegistered($user, $account, $provider, $providerAccount);
- }
-
- return $this->register($provider, $providerAccount);
- }
-
- if (! Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with this :Provider sign in was not found. Please register or try a different sign in method.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
- );
- }
-
- if (Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
- if (Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->exists()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with that email address already exists. Please login to connect your :Provider account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
- );
- }
-
- $user = $this->createsUser->create($provider, $providerAccount);
-
- return $this->login($user);
- }
-
- $user = $account->user;
-
- $this->updatesConnectedAccounts->update($user, $account, $provider, $providerAccount);
-
- return $this->login($user);
- }
-
- /**
- * Handle connection of accounts for an already authenticated user.
- */
- protected function alreadyAuthenticated(Authenticatable $user, ?ConnectedAccount $account, string $provider, ProviderUser $providerAccount): RedirectResponse
- {
- // Connect the account to the user.
- if (! $account) {
- $this->createsConnectedAccounts->create($user, $provider, $providerAccount);
-
- return redirect()->route('profile.edit')->with(
- 'status', __('You have successfully connected :Provider to your account.', ['provider' => Providers::name($provider)])
- );
- }
-
- if ($account->user_id !== $user->id) {
- return redirect()->route('profile.edit')->withErrors(
- ['callback' => __('This :Provider sign in account is already associated with another user. Please log in with that user or connect a different :Provider account.', ['provider' => Providers::name($provider)])]
- );
- }
-
- // Account already connected
- return redirect()->route('profile.edit')->withErrors(
- ['callback' => __('This :Provider sign in account is already associated with your user.', ['provider' => Providers::name($provider)])]
- );
- }
-
- /**
- * Handle when a user is already registered.
- */
- protected function alreadyRegistered(Authenticatable $user, ?ConnectedAccount $account, string $provider, ProviderUser $providerAccount): RedirectResponse
- {
- if (Features::hasLoginOnRegistrationFeatures()) {
- // The user exists, but they're not registered with the given provider.
- if (! $account) {
- $this->createsConnectedAccounts->create($user, $provider, $providerAccount);
- }
-
- return $this->login($user);
- }
-
- $messageBag = new MessageBag;
- $messageBag->add('socialstream', __('An account with that :Provider sign in already exists, please login.', ['provider' => Providers::name($provider)]));
-
- return redirect()->route('login')->withErrors($messageBag);
- }
-
- /**
- * Handle the registration of a new user.
- */
- protected function register(string $provider, ProviderUser $providerAccount): RedirectResponse
- {
- if (! $providerAccount->getEmail()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('No email address is associated with this :Provider account. Please try a different account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('register')->withErrors($messageBag);
- }
-
- if (Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->exists()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with that email address already exists. Please login to connect your :Provider account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('register')->withErrors($messageBag);
- }
-
- $user = $this->createsUser->create($provider, $providerAccount);
-
- return $this->login($user);
- }
-
- /**
- * Authenticate the given user and return a login response.
- */
- protected function login(Authenticatable $user): RedirectResponse
- {
- $this->guard->login($user, Socialstream::hasRememberSessionFeatures());
-
- return redirect('/dashboard');
- }
-}
diff --git a/src/Actions/Auth/Breeze/HandleOAuthCallbackErrors.php b/src/Actions/Auth/Breeze/HandleOAuthCallbackErrors.php
deleted file mode 100644
index 57b5e48a..00000000
--- a/src/Actions/Auth/Breeze/HandleOAuthCallbackErrors.php
+++ /dev/null
@@ -1,29 +0,0 @@
-has('error')) {
- return null;
- }
-
- $messageBag = new MessageBag;
- $messageBag->add('socialstream', $request->get('error_description'));
-
- return auth()->check()
- ? redirect(RouteServiceProvider::HOME)->withErrors(['callback' => $request->get('error_description')])
- : redirect()->route('login')->withErrors($messageBag);
- }
-}
diff --git a/src/Actions/Auth/Breeze/Livewire/AuthenticateOAuthCallback.php b/src/Actions/Auth/Breeze/Livewire/AuthenticateOAuthCallback.php
deleted file mode 100644
index dfde8f34..00000000
--- a/src/Actions/Auth/Breeze/Livewire/AuthenticateOAuthCallback.php
+++ /dev/null
@@ -1,211 +0,0 @@
-getId());
-
- // Authenticated...
- if (! is_null($user = auth()->user())) {
- return $this->alreadyAuthenticated($user, $account, $provider, $providerAccount);
- }
-
- // Registration...
- $previousUrl = session()->get('socialstream.previous_url');
-
- if (
- $previousUrl === route('register') ||
- (Features::hasCreateAccountOnFirstLoginFeatures() && $previousUrl === route('login'))
- ) {
- $user = Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->first();
-
- if ($user) {
- return $this->alreadyRegistered($user, $account, $provider, $providerAccount);
- }
-
- return $this->register($provider, $providerAccount);
- }
-
- if (! Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with this :Provider sign in was not found. Please register or try a different sign in method.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
- );
- }
-
- if (Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
- if (Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->exists()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with that email address already exists. Please login to connect your :Provider account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
- );
- }
-
- $user = $this->createsUser->create($provider, $providerAccount);
-
- return $this->login($user);
- }
-
- if (! Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with this :Provider sign in was not found. Please register or try a different sign in method.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
- );
- }
-
- if (Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
- if (Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->exists()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with that email address already exists. Please login to connect your :Provider account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
- );
- }
-
- $user = $this->createsUser->create($provider, $providerAccount);
-
- return $this->login($user);
- }
-
- $user = $account->user;
-
- $this->updatesConnectedAccounts->update($user, $account, $provider, $providerAccount);
-
- return $this->login($user);
- }
-
- /**
- * Handle connection of accounts for an already authenticated user.
- */
- protected function alreadyAuthenticated(Authenticatable $user, ?ConnectedAccount $account, string $provider, ProviderUser $providerAccount): RedirectResponse
- {
- // Connect the account to the user.
- if (! $account) {
- $this->createsConnectedAccounts->create($user, $provider, $providerAccount);
-
- return redirect()->route('profile')->with(
- 'status', __('You have successfully connected :Provider to your account.', ['provider' => Providers::name($provider)])
- );
- }
-
- if ($account->user_id !== $user->id) {
- return redirect()->route('profile')->withErrors(
- ['callback' => __('This :Provider sign in account is already associated with another user. Please log in with that user or connect a different :Provider account.', ['provider' => Providers::name($provider)])]
- );
- }
-
- // Account already connected
- return redirect()->route('profile')->withErrors(
- ['callback' => __('This :Provider sign in account is already associated with your user.', ['provider' => Providers::name($provider)])]
- );
- }
-
- /**
- * Handle when a user is already registered.
- */
- protected function alreadyRegistered(Authenticatable $user, ?ConnectedAccount $account, string $provider, ProviderUser $providerAccount): RedirectResponse
- {
- if (Features::hasLoginOnRegistrationFeatures()) {
- // The user exists, but they're not registered with the given provider.
- if (! $account) {
- $this->createsConnectedAccounts->create($user, $provider, $providerAccount);
- }
-
- return $this->login($user);
- }
-
- $messageBag = new MessageBag;
- $messageBag->add('socialstream', __('An account with that :Provider sign in already exists, please login.', ['provider' => Providers::name($provider)]));
-
- return redirect()->route('login')->withErrors($messageBag);
- }
-
- /**
- * Handle the registration of a new user.
- */
- protected function register(string $provider, ProviderUser $providerAccount): RedirectResponse
- {
- if (! $providerAccount->getEmail()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('No email address is associated with this :Provider account. Please try a different account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('register')->withErrors($messageBag);
- }
-
- if (Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->exists()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with that email address already exists. Please login to connect your :Provider account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('register')->withErrors($messageBag);
- }
-
- $user = $this->createsUser->create($provider, $providerAccount);
-
- return $this->login($user);
- }
-
- /**
- * Authenticate the given user and return a login response.
- */
- protected function login(Authenticatable $user): RedirectResponse
- {
- $this->guard->login($user, Socialstream::hasRememberSessionFeatures());
-
- return redirect('/dashboard');
- }
-}
diff --git a/src/Actions/Auth/Filament/AuthenticateOAuthCallback.php b/src/Actions/Auth/Filament/AuthenticateOAuthCallback.php
deleted file mode 100644
index 62502fbc..00000000
--- a/src/Actions/Auth/Filament/AuthenticateOAuthCallback.php
+++ /dev/null
@@ -1,46 +0,0 @@
-user();
-
- if (! $user) {
- $user = Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->first()
- ?? $this->createsUser->create($provider, $providerAccount);
- }
-
- ($account = Socialstream::findConnectedAccountForProviderAndId($provider, $providerAccount->getId()))
- ? $this->updatesConnectedAccounts->update($user, $account, $provider, $providerAccount)
- : $this->createsConnectedAccounts->create($user, $provider, $providerAccount);
-
- $this->guard->login($user, Socialstream::hasRememberSessionFeatures());
-
- return redirect()->route('filament.admin.home');
- }
-}
diff --git a/src/Actions/Auth/Filament/HandleOAuthCallbackErrors.php b/src/Actions/Auth/Filament/HandleOAuthCallbackErrors.php
deleted file mode 100644
index dbd0b0db..00000000
--- a/src/Actions/Auth/Filament/HandleOAuthCallbackErrors.php
+++ /dev/null
@@ -1,30 +0,0 @@
-has('error')) {
- return null;
- }
-
- $messageBag = new MessageBag;
- $messageBag->add('socialstream', $request->get('error_description'));
-
- return auth()->check()
- ? redirect()->route('filament.home')->withErrors($messageBag)
- : redirect()->route(
- 'filament.admin.auth.login'
- )->withErrors($messageBag);
- }
-}
diff --git a/src/Actions/Auth/Jetstream/HandleOAuthCallbackErrors.php b/src/Actions/Auth/Jetstream/HandleOAuthCallbackErrors.php
deleted file mode 100644
index ced7455f..00000000
--- a/src/Actions/Auth/Jetstream/HandleOAuthCallbackErrors.php
+++ /dev/null
@@ -1,31 +0,0 @@
-has('error')) {
- return null;
- }
-
- $messageBag = new MessageBag;
- $messageBag->add('socialstream', $request->get('error_description'));
-
- return auth()->check()
- ? redirect(config('fortify.home'))->dangerBanner($request->get('error_description'))
- : redirect()->route(
- FortifyFeatures::enabled(FortifyFeatures::registration()) ? 'register' : 'login'
- )->withErrors($messageBag);
- }
-}
diff --git a/src/Actions/Auth/Jetstream/AuthenticateOAuthCallback.php b/src/Actions/AuthenticateOAuthCallback.php
similarity index 69%
rename from src/Actions/Auth/Jetstream/AuthenticateOAuthCallback.php
rename to src/Actions/AuthenticateOAuthCallback.php
index 0c964c42..7095e839 100644
--- a/src/Actions/Auth/Jetstream/AuthenticateOAuthCallback.php
+++ b/src/Actions/AuthenticateOAuthCallback.php
@@ -1,12 +1,15 @@
get('socialstream.previous_url');
if (
+ class_exists(FortifyFeatures::class) &&
FortifyFeatures::enabled(FortifyFeatures::registration()) && ! $account &&
(
$previousUrl === route('register') ||
@@ -62,27 +68,15 @@ public function authenticate(string $provider, ProviderUser $providerAccount): R
}
if (! Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with this :Provider sign in was not found. Please register or try a different sign in method.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
+ 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 (Features::hasCreateAccountOnFirstLoginFeatures() && ! $account) {
if (Socialstream::newUserModel()->where('email', $providerAccount->getEmail())->exists()) {
- $messageBag = new MessageBag;
- $messageBag->add(
- 'socialstream',
- __('An account with that email address already exists. Please login to connect your :Provider account.', ['provider' => Providers::name($provider)])
- );
-
- return redirect()->route('login')->withErrors(
- $messageBag
+ return $this->redirectAuthFailed(
+ error: __('An account with that email address already exists. Please login to connect your :Provider account.', ['provider' => Providers::name($provider)])
);
}
@@ -138,10 +132,9 @@ protected function alreadyRegistered(Authenticatable $user, ?ConnectedAccount $a
return $this->login($user);
}
- $messageBag = new MessageBag;
- $messageBag->add('socialstream', __('An account with that :Provider sign in already exists, please login.', ['provider' => Providers::buttonLabel($provider)]));
-
- return redirect()->route('login')->withErrors($messageBag);
+ return $this->redirectAuthFailed(
+ __('An account with that :Provider sign in already exists, please login.', ['provider' => Providers::buttonLabel($provider)])
+ );
}
/**
@@ -177,10 +170,40 @@ protected function register(string $provider, ProviderUser $providerAccount): Re
/**
* Authenticate the given user and return a login response.
*/
- protected function login(Authenticatable $user): LoginResponse
+ protected function login(Authenticatable $user): RedirectResponse|LoginResponse
{
$this->guard->login($user, Socialstream::hasRememberSessionFeatures());
- return app(LoginResponse::class);
+ // Because users can have multiple stacks installed for which they may wish to use
+ // Socialstream for, we will need to determine the redirect path based on a few
+ // different factors, such as the presence of Filament's auth routes etc.
+
+ $previousUrl = session()->pull('socialstream.previous_url');
+
+ return match (true) {
+ Route::has('filament.auth.login') && $previousUrl === route('filament.auth.login') => redirect()
+ ->route('admin'),
+ $this->hasComposerPackage('laravel/breeze') => redirect()
+ ->route('dashboard'),
+ $this->hasComposerPackage('laravel/jetstream') => app(LoginResponse::class),
+ default => redirect()
+ ->to(RouteServiceProvider::HOME),
+ };
+ }
+
+ private function redirectAuthFailed(string $error): RedirectResponse
+ {
+ $previousUrl = session()->pull('socialstream.previous_url');
+
+ // Because users can have multiple stacks installed for which they may wish to use
+ // Socialstream for, we will need to determine the redirect path based on a few
+ // different factors, such as the presence of Filament's auth routes etc.
+
+ return redirect()->route(match (true) {
+ Route::has('login') && $previousUrl === route('login') => 'login',
+ Route::has('register') && $previousUrl === route('register') => 'register',
+ Route::has('filament.auth.login') && $previousUrl === route('filament.auth.login') => 'filament.auth.login',
+ default => 'login',
+ })->withErrors((new MessageBag)->add('socialstream', $error));
}
}
diff --git a/src/Actions/GenerateRedirectForProvider.php b/src/Actions/GenerateRedirectForProvider.php
index 7dad653a..92b8dd81 100644
--- a/src/Actions/GenerateRedirectForProvider.php
+++ b/src/Actions/GenerateRedirectForProvider.php
@@ -13,6 +13,11 @@ class GenerateRedirectForProvider implements GeneratesProviderRedirect
*/
public function generate(string $provider): RedirectResponse
{
+ session()->put(
+ key: 'socialstream.previous_url',
+ value: url()->previous(),
+ );
+
return Socialite::driver($provider)->redirect();
}
}
diff --git a/src/Actions/HandleOAuthCallbackErrors.php b/src/Actions/HandleOAuthCallbackErrors.php
new file mode 100644
index 00000000..b7849398
--- /dev/null
+++ b/src/Actions/HandleOAuthCallbackErrors.php
@@ -0,0 +1,66 @@
+has('error')) {
+ return null;
+ }
+
+ $error = $request->get('error_description');
+
+ // Because users can have multiple stacks installed for which they may wish to use
+ // Socialstream for, we will need to determine the redirect path based on a few
+ // different factors, such as the presence of Filament's auth routes etc.
+
+ if (! auth()->check()) {
+ return $this->unauthenticatedRedirectWithError($error);
+ }
+
+ $previousUrl = session()->pull('socialstream.previous_url');
+
+ return match (true) {
+ Route::has('filament.home') && $previousUrl === route('filament.home') => redirect()
+ ->route('filament.home')
+ ->withErrors((new MessageBag)->add('socialstream', $error)),
+ $this->hasComposerPackage('laravel/breeze') => redirect()
+ ->route(match (true) {
+ Route::has('profile.show') => 'profile.show',
+ Route::has('profile.edit') => 'profile.edit',
+ Route::has('profile') => 'profile',
+ })
+ ->withErrors(['callback' => $error]),
+ default => redirect()
+ ->route('profile.show')
+ ->dangerBanner($error),
+ };
+ }
+
+ private function unauthenticatedRedirectWithError(string $error): RedirectResponse
+ {
+ $previousUrl = session()->pull('socialstream.previous_url');
+
+ if (Route::has('filament.admin.auth.login') && $previousUrl === route('filament.admin.auth.login')) {
+ return redirect()
+ ->route('filament.admin.auth.login')
+ ->withErrors((new MessageBag)->add('socialstream', $error));
+ }
+
+ return redirect()->route('login')->withErrors((new MessageBag)->add('socialstream', $error));
+ }
+}
diff --git a/src/Http/Livewire/ConnectedAccountsForm.php b/src/Http/Livewire/ConnectedAccountsForm.php
index 8ff0d16b..b58f4c47 100644
--- a/src/Http/Livewire/ConnectedAccountsForm.php
+++ b/src/Http/Livewire/ConnectedAccountsForm.php
@@ -81,7 +81,7 @@ public function setAvatarAsProfilePhoto(string|int $id): void
$user->setProfilePhotoFromUrl($account->avatar_path);
}
- session()->flash('flash.banner', __('Profile photo updated'));
+ $this->banner(__('Profile photo updated'));
redirect()->route('profile.show');
}
@@ -104,7 +104,7 @@ public function removeConnectedAccount(): void
->where('user_id', auth()->user()->id)
->delete();
- session()->flash('flash.banner', __('Account removed'));
+ $this->banner(__('Account removed.'));
redirect()->route('profile.show');
}
diff --git a/src/Http/Livewire/SetPasswordForm.php b/src/Http/Livewire/SetPasswordForm.php
index 407860c5..ca2594c9 100644
--- a/src/Http/Livewire/SetPasswordForm.php
+++ b/src/Http/Livewire/SetPasswordForm.php
@@ -4,10 +4,13 @@
use Illuminate\View\View;
use JoelButcher\Socialstream\Contracts\SetsUserPasswords;
+use Laravel\Jetstream\InteractsWithBanner;
use Livewire\Component;
class SetPasswordForm extends Component
{
+ use InteractsWithBanner;
+
/**
* The component's state.
*
@@ -32,7 +35,7 @@ public function setPassword(SetsUserPasswords $setter): void
'password_confirmation' => '',
];
- session()->flash('flash.banner', __('Your password has been set.'));
+ $this->banner(__('Your password has been set.'));
redirect()->route('profile.show');
}
diff --git a/src/Installer/Drivers/Jetstream/JetstreamDriver.php b/src/Installer/Drivers/Jetstream/JetstreamDriver.php
index 07832201..7f4ce649 100644
--- a/src/Installer/Drivers/Jetstream/JetstreamDriver.php
+++ b/src/Installer/Drivers/Jetstream/JetstreamDriver.php
@@ -21,7 +21,7 @@ abstract class JetstreamDriver extends Driver
abstract protected static function stack(): JetstreamInstallStack;
/**
- * Check for, and install Laravel Jetstream, if required,.
+ * Check for, and install Laravel Jetstream, if required.
*/
protected function ensureDependenciesAreInstalled(string $composerBinary, InstallOptions ...$options): void
{
diff --git a/src/SetsProfilePhotoFromUrl.php b/src/SetsProfilePhotoFromUrl.php
index 6db7f852..7918f9a1 100644
--- a/src/SetsProfilePhotoFromUrl.php
+++ b/src/SetsProfilePhotoFromUrl.php
@@ -22,7 +22,7 @@ public function setProfilePhotoFromUrl(string $url): void
$this->updateProfilePhoto(new UploadedFile($file, $name));
} else {
- session()->flash('flash.banner', 'Unable to retrive image');
+ session()->flash('flash.banner', 'Unable to retrieve image');
session()->flash('flash.bannerStyle', 'danger');
}
}
diff --git a/src/SocialstreamServiceProvider.php b/src/SocialstreamServiceProvider.php
index f27e546a..ba4c0d2b 100644
--- a/src/SocialstreamServiceProvider.php
+++ b/src/SocialstreamServiceProvider.php
@@ -6,18 +6,13 @@
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\Compilers\BladeCompiler;
-use JoelButcher\Socialstream\Actions\Auth\Breeze\Blade\AuthenticateOAuthCallback as BreezeBladeAuthenticateOAuthCallback;
-use JoelButcher\Socialstream\Actions\Auth\Breeze\HandleOAuthCallbackErrors as BreezeHandleOAuthCallbackErrors;
-use JoelButcher\Socialstream\Actions\Auth\Breeze\Livewire\AuthenticateOAuthCallback as BreezeLivewireAuthenticateOAuthCallback;
-use JoelButcher\Socialstream\Actions\Auth\Filament\AuthenticateOAuthCallback as FilamentAuthenticateOAuthCallback;
-use JoelButcher\Socialstream\Actions\Auth\Filament\HandleOAuthCallbackErrors as FilamentHandleOAuthCallbackErrors;
-use JoelButcher\Socialstream\Actions\Auth\Jetstream\AuthenticateOAuthCallback as JetstreamAuthenticateOAuthCallback;
-use JoelButcher\Socialstream\Actions\Auth\Jetstream\HandleOAuthCallbackErrors as JetstreamHandleOAuthCallbackErrors;
+use JoelButcher\Socialstream\Actions\AuthenticateOAuthCallback;
use JoelButcher\Socialstream\Actions\CreateConnectedAccount;
use JoelButcher\Socialstream\Actions\CreateUserFromProvider;
use JoelButcher\Socialstream\Actions\CreateUserWithTeamsFromProvider;
use JoelButcher\Socialstream\Actions\GenerateRedirectForProvider;
use JoelButcher\Socialstream\Actions\HandleInvalidState;
+use JoelButcher\Socialstream\Actions\HandleOAuthCallbackErrors;
use JoelButcher\Socialstream\Actions\ResolveSocialiteUser;
use JoelButcher\Socialstream\Actions\SetUserPassword;
use JoelButcher\Socialstream\Actions\UpdateConnectedAccount;
@@ -60,6 +55,9 @@ public function register(): void
*/
public function boot(): void
{
+ Socialstream::authenticatesOAuthCallbackUsing(AuthenticateOAuthCallback::class);
+ Socialstream::handlesOAuthCallbackErrorsUsing(HandleOAuthCallbackErrors::class);
+
$this->configureRoutes();
$this->configureCommands();
$this->configureActions();
@@ -68,10 +66,13 @@ public function boot(): void
match (true) {
$this->hasComposerPackage('laravel/breeze') => $this->bootLaravelBreeze(),
$this->hasComposerPackage('laravel/jetstream') => $this->bootLaravelJetstream(),
- $this->hasComposerPackage('filament/filament') => $this->bootFilament(),
default => null,
};
+ if ($this->hasComposerPackage('filament/filament')) {
+ $this->bootFilament();
+ }
+
if ($this->hasComposerPackage('inertiajs/inertia-laravel')) {
$this->bootInertia();
}
@@ -159,9 +160,6 @@ protected function configureRefreshTokenResolvers(): void
protected function bootLaravelJetstream(): void
{
Socialstream::setUserPasswordsUsing(SetUserPassword::class);
- Socialstream::authenticatesOAuthCallbackUsing(JetstreamAuthenticateOAuthCallback::class);
- Socialstream::handlesOAuthCallbackErrorsUsing(JetstreamHandleOAuthCallbackErrors::class);
-
if (! $this->app->runningInConsole()) {
return;
}
@@ -191,12 +189,6 @@ protected function bootLaravelJetstream(): void
*/
protected function bootLaravelBreeze(): void
{
- Socialstream::handlesOAuthCallbackErrorsUsing(BreezeHandleOAuthCallbackErrors::class);
- Socialstream::authenticatesOAuthCallbackUsing(match (true) {
- class_exists('\App\Providers\VoltServiceProvider') => BreezeLivewireAuthenticateOAuthCallback::class,
- default => BreezeBladeAuthenticateOAuthCallback::class,
- });
-
if (! $this->app->runningInConsole()) {
return;
}
@@ -238,9 +230,6 @@ class_exists('\App\Providers\VoltServiceProvider') => BreezeLivewireAuthenticate
*/
protected function bootFilament(): void
{
- Socialstream::authenticatesOAuthCallbackUsing(FilamentAuthenticateOAuthCallback::class);
- Socialstream::handlesOAuthCallbackErrorsUsing(FilamentHandleOAuthCallbackErrors::class);
-
$this->loadViewsFrom(__DIR__.'/../resources/filament/views', 'socialstream');
if (! $this->app->runningInConsole()) {
diff --git a/tests/Feature/SocialstreamTest.php b/tests/Feature/SocialstreamTest.php
index b3e383d0..faf78f06 100644
--- a/tests/Feature/SocialstreamTest.php
+++ b/tests/Feature/SocialstreamTest.php
@@ -3,6 +3,7 @@
namespace JoelButcher\Socialstream\Tests\Feature;
use App\Models\User;
+use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Config;
@@ -94,7 +95,7 @@ public function generate(string $provider): RedirectResponse
$response = get('http://localhost/oauth/github/callback');
- $response->assertRedirect('/home');
+ $response->assertRedirect(RouteServiceProvider::HOME);
$this->assertAuthenticated();
$this->assertDatabaseHas('users', ['email' => 'joel@socialstream.dev']);
@@ -145,7 +146,7 @@ public function generate(string $provider): RedirectResponse
Socialite::shouldReceive('driver')->once()->with('github')->andReturn($provider);
get('http://localhost/oauth/github/callback')
- ->assertRedirect('/home');
+ ->assertRedirect(RouteServiceProvider::HOME);
$this->assertAuthenticated();
});
@@ -216,7 +217,7 @@ public function generate(string $provider): RedirectResponse
Socialite::shouldReceive('driver')->once()->with('github')->andReturn($provider);
get('http://localhost/oauth/github/callback')
- ->assertRedirect('/home');
+ ->assertRedirect(RouteServiceProvider::HOME);
$this->assertAuthenticated();
$this->assertDatabaseHas('connected_accounts', [
@@ -261,7 +262,7 @@ public function generate(string $provider): RedirectResponse
session()->put('socialstream.previous_url', route('register'));
get('http://localhost/oauth/github/callback')
- ->assertRedirect('/home');
+ ->assertRedirect(RouteServiceProvider::HOME);
$this->assertAuthenticated();
$this->assertDatabaseHas('connected_accounts', [
@@ -296,7 +297,7 @@ public function generate(string $provider): RedirectResponse
session()->put('socialstream.previous_url', route('register'));
get('http://localhost/oauth/github/callback')
- ->assertRedirect('/home');
+ ->assertRedirect(RouteServiceProvider::HOME);
$user = User::first();
diff --git a/tests/JetstreamTestCase.php b/tests/JetstreamTestCase.php
index 8b17b266..1aa3d559 100644
--- a/tests/JetstreamTestCase.php
+++ b/tests/JetstreamTestCase.php
@@ -3,11 +3,12 @@
namespace JoelButcher\Socialstream\Tests;
use Illuminate\Support\Facades\Config;
-use JoelButcher\Socialstream\Actions\Auth\Jetstream\AuthenticateOAuthCallback;
-use JoelButcher\Socialstream\Actions\Auth\Jetstream\HandleOAuthCallbackErrors;
+use JoelButcher\Socialstream\Actions\AuthenticateOAuthCallback;
+use JoelButcher\Socialstream\Actions\HandleOAuthCallbackErrors;
use JoelButcher\Socialstream\Socialstream;
use Laravel\Fortify\FortifyServiceProvider;
use Laravel\Jetstream\JetstreamServiceProvider;
+use Livewire\LivewireServiceProvider;
abstract class JetstreamTestCase extends TestCase
{
@@ -26,7 +27,7 @@ protected function getPackageProviders($app): array
{
return array_merge(
parent::getPackageProviders($app),
- [JetstreamServiceProvider::class, FortifyServiceProvider::class]
+ [LivewireServiceProvider::class, JetstreamServiceProvider::class, FortifyServiceProvider::class]
);
}
}
diff --git a/workbench/app/Providers/RouteServiceProvider.php b/workbench/app/Providers/RouteServiceProvider.php
new file mode 100644
index 00000000..3c46a886
--- /dev/null
+++ b/workbench/app/Providers/RouteServiceProvider.php
@@ -0,0 +1,10 @@
+