Skip to content

Commit

Permalink
Merge pull request #103 from jeffgreco13/1.x-dev
Browse files Browse the repository at this point in the history
fix: switch to optional route name prefix
  • Loading branch information
jeffgreco13 authored Aug 7, 2022
2 parents 6bb16dc + bebc600 commit 81f03f3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
],
....
```
Expand Down
6 changes: 5 additions & 1 deletion config/filament-breezy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions resources/views/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@if(config("filament-breezy.enable_registration"))
<p class="mt-2 text-sm text-center">
{{ __('filament-breezy::default.or') }}
<a class="text-primary-600" href="{{route('filament.register')}}">
<a class="text-primary-600" href="{{route(config('filament-breezy.route_group_prefix').'register')}}">
{{ strtolower(__('filament-breezy::default.registration.heading')) }}
</a>
</p>
Expand All @@ -25,6 +25,6 @@
</x-filament::button>

<div class="text-center">
<a class="text-primary-600 hover:text-primary-700" href="{{route('filament.password.request')}}">{{ __('filament-breezy::default.login.forgot_password_link') }}</a>
<a class="text-primary-600 hover:text-primary-700" href="{{route(config('filament-breezy.route_group_prefix').'password.request')}}">{{ __('filament-breezy::default.login.forgot_password_link') }}</a>
</div>
</x-filament-breezy::auth-card>
9 changes: 5 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions src/FilamentBreezyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,10 +59,6 @@ public function packageBooted(): void
]);
});
}

ResetPassword::createUrlUsing(function ($user, string $token) {
return route('filament.password.reset', ['token' => $token]);
});
}

protected function getPages(): array
Expand Down

0 comments on commit 81f03f3

Please sign in to comment.