Skip to content

Commit

Permalink
Fix 2fa page and prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgreco13 committed Aug 1, 2023
1 parent fcda3d2 commit 56ea98d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
11 changes: 6 additions & 5 deletions resources/views/filament/pages/two-factor.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div>
<form wire:submit.prevent="authenticate" class="grid gap-y-8">
<x-filament-panels::page.simple>
<x-filament-panels::form wire:submit="authenticate">
{{ $this->form }}

<x-filament::button type="submit" form="authenticate">Submit</x-filament::button>
</form>
</div>
<x-filament-panels::form.actions :actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()" />
</x-filament-panels::form>
</x-filament-panels::page.simple>
3 changes: 1 addition & 2 deletions src/Middleware/MustTwoFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class MustTwoFactor
public function handle(Request $request, Closure $next): Response
{
$breezy = filament('filament-breezy');

if($breezy->auth()->check()){
if($breezy->auth()->check() && !$request->routeIs('filament.admin.auth.logout')){
// Logged in.
$myProfileRouteName = 'filament.' . filament('filament-breezy')->getCurrentPanel()->getId() . '.pages.my-profile';
if ($breezy->shouldForceTwoFactor() && !$request->routeIs($myProfileRouteName)){
Expand Down
19 changes: 15 additions & 4 deletions src/Pages/TwoFactorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
use Filament\Actions\Action;
// use Filament\Pages\CardPage;
use Filament\Facades\Filament;
use Filament\Pages\SimplePage;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Facades\Blade;
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Filament\Http\Controllers\Auth\LogoutController;
use Filament\Pages\Concerns\InteractsWithFormActions;
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
use Filament\Pages\SimplePage;

class TwoFactorPage extends SimplePage
{
use InteractsWithFormActions;
use WithRateLimiting;

protected static string $view = 'filament-breezy::filament.pages.two-factor';
Expand All @@ -38,7 +40,6 @@ public function mount()
} else if (filament('filament-breezy')->auth()->user()->hasValidTwoFactorSession()){
return redirect()->to(Filament::getHomeUrl());
}
// return parent::mount();
}

protected function getFormSchema(): array
Expand Down Expand Up @@ -72,10 +73,20 @@ public function hasValidCode()
}
}

public function authenticateAction(): Action
/**
* @return array<Action | ActionGroup>
*/
protected function getFormActions(): array
{
return [
$this->getAuthenticateFormAction(),
];
}

protected function getAuthenticateFormAction(): Action
{
return Action::make('authenticate')
->label(__('filament::pages/auth/login.buttons.authenticate.label'))
->label(__('filament-panels::pages/auth/login.form.actions.authenticate.label'))
->submit('authenticate');
}

Expand Down

0 comments on commit 56ea98d

Please sign in to comment.