Skip to content

Commit

Permalink
Update forced method to accept Closure type (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithDennis authored Sep 20, 2024
1 parent 9ad9651 commit 1d1f44f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/TwoFactorAuthPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

namespace Vormkracht10\TwoFactorAuth;

use Closure;
use Filament\Contracts\Plugin;
use Filament\Navigation\MenuItem;
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;
use Vormkracht10\TwoFactorAuth\Http\Middleware\ForceTwoFactor;
use Vormkracht10\TwoFactorAuth\Pages\TwoFactor;

class TwoFactorAuthPlugin implements Plugin
{
private bool $forced = false;
use EvaluatesClosures;

private Closure | bool | null $forced = false;

public function getId(): string
{
Expand Down Expand Up @@ -65,15 +69,15 @@ public static function get(): static
return $plugin;
}

public function forced(bool $forced = true, bool $withTenancy = false): self
public function forced(Closure | bool | null $forced = true, bool $withTenancy = false): self
{
$this->forced = $forced;

return $this;
}

public function isForced(): bool
public function isForced(): Closure | bool | null
{
return $this->forced;
return $this->evaluate($this->forced);
}
}

0 comments on commit 1d1f44f

Please sign in to comment.