From d7b2e45804d02b057240ba57cc6f7c3d3879abbc Mon Sep 17 00:00:00 2001 From: Jeff Greco Date: Sun, 7 Aug 2022 15:04:10 -0400 Subject: [PATCH 1/2] fix: switch to optional route name prefix Allow devs to use a custom route prefix for auth routes. --- README.md | 16 ++++++++++++---- config/filament-breezy.php | 6 +++++- resources/views/login.blade.php | 4 ++-- routes/web.php | 9 +++++---- src/FilamentBreezyServiceProvider.php | 4 ---- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 42d60b1..b88a492 100644 --- a/README.md +++ b/README.md @@ -127,21 +127,29 @@ use Illuminate\Contracts\Auth\MustVerifyEmail; class User extends Authenticatable implements MustVerifyEmail ``` -Then you can add the `verified:filament.verification.notice` middleware to any of your routes: +Then you can add the `verified` middleware to any of your routes: ```php Route::get("/profile", function () { // Only verified users may access this route... -})->middleware('verified:filament.verification.notice'); +})->middleware('verified'); ``` -Or, force verified emails on your entire Filament Admin by adding the `verified:filament.verification.notice` class to the auth middleware in `config/filament.php`: +Or, if you're using a custom route name prefix: + +```php +Route::get("/profile", function () { + // Only verified users may access this route... +})->middleware('verified:my-prefix.verification.notice'); +``` + +To force verified emails on your entire Filament Admin by adding the `verified` class to the auth middleware in `config/filament.php`: ```php "middleware" => [ "auth" => [ Authenticate::class, - 'verified:filament.verification.notice' + 'verified' ], .... ``` diff --git a/config/filament-breezy.php b/config/filament-breezy.php index 554230f..314f42e 100644 --- a/config/filament-breezy.php +++ b/config/filament-breezy.php @@ -45,7 +45,11 @@ | The column to use for login/username authentication. NOTE: this may change to just 'login_field' in a later release. */ "fallback_login_field" => "email", - + /* + |-------------------------------------------------------------------------- + | Set a route name prefix for all of Breezy's auth routes. Ex. set filament. to prefix all route names, filament.register. WARNING: if you use a custom route prefix, you'll need to override the default auth routes used throughout your application. This is outside of Breezy's scope and will be up to the dev to maintain. Use at your own risk. See example: https://laravel.com/docs/9.x/passwords#password-customization + */ + "route_group_prefix"=>'', /* |-------------------------------------------------------------------------- | Enable Two-Factor Authentication (2FA). diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php index 6565c5b..8dd8c4b 100644 --- a/resources/views/login.blade.php +++ b/resources/views/login.blade.php @@ -11,7 +11,7 @@ @if(config("filament-breezy.enable_registration"))

{{ __('filament-breezy::default.or') }} - + {{ strtolower(__('filament-breezy::default.registration.heading')) }}

@@ -25,6 +25,6 @@
- {{ __('filament-breezy::default.login.forgot_password_link') }} + {{ __('filament-breezy::default.login.forgot_password_link') }}
diff --git a/routes/web.php b/routes/web.php index 9fdae77..748f5c2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,23 +5,24 @@ Route::domain(config("filament.domain")) ->middleware(config("filament.middleware.base")) + ->name(config('filament-breezy.route_group_prefix')) ->prefix(config("filament.path")) ->group(function () { // Login will be replaced in the Filament config. if (config("filament-breezy.enable_registration")) { - Route::get("/register", config('filament-breezy.registration_component_path'))->name("filament.register"); + Route::get("/register", config('filament-breezy.registration_component_path'))->name("register"); } Route::get("/password/reset", config('filament-breezy.password_reset_component_path'))->name( - "filament.password.request" + "password.request" ); Route::get("/password/reset/{token}", config('filament-breezy.password_reset_component_path'))->name( - "filament.password.reset" + "password.reset" ); Route::get("email/verify", config('filament-breezy.email_verification_component_path')) ->middleware(["throttle:6,1","auth"]) - ->name("filament.verification.notice"); + ->name("verification.notice"); Route::get("email/verify/{id}/{hash}", [ EmailVerificationController::class, diff --git a/src/FilamentBreezyServiceProvider.php b/src/FilamentBreezyServiceProvider.php index 6c01baa..88ac86c 100644 --- a/src/FilamentBreezyServiceProvider.php +++ b/src/FilamentBreezyServiceProvider.php @@ -60,10 +60,6 @@ public function packageBooted(): void ]); }); } - - ResetPassword::createUrlUsing(function ($user, string $token) { - return route('filament.password.reset', ['token' => $token]); - }); } protected function getPages(): array From bebc600a8bdc2c4fd20d35ba9afe330ee62a6657 Mon Sep 17 00:00:00 2001 From: jeffgreco13 Date: Sun, 7 Aug 2022 19:04:31 +0000 Subject: [PATCH 2/2] Fix styling --- src/FilamentBreezyServiceProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FilamentBreezyServiceProvider.php b/src/FilamentBreezyServiceProvider.php index 88ac86c..f594b50 100644 --- a/src/FilamentBreezyServiceProvider.php +++ b/src/FilamentBreezyServiceProvider.php @@ -5,7 +5,6 @@ use Filament\Facades\Filament; use Filament\Navigation\UserMenuItem; use Filament\PluginServiceProvider; -use Illuminate\Auth\Notifications\ResetPassword; use JeffGreco13\FilamentBreezy\Commands\FilamentBreezyCommand; use JeffGreco13\FilamentBreezy\Http\Livewire\Auth; use JeffGreco13\FilamentBreezy\Http\Livewire\BreezySanctumTokens;