Skip to content

Commit

Permalink
Merge pull request #404 from Jacobtims/feat/twofa-force-closure
Browse files Browse the repository at this point in the history
Allow the use of closures in the two-factor method's force parameter
  • Loading branch information
jeffgreco13 authored Jan 14, 2025
2 parents 94d1675 + ddcc94c commit 2d389fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/BreezyCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function getNavigationGroup(string $key)
return $this->{$key}['navigationGroup'] ?? null;
}

public function enableTwoFactorAuthentication(bool $condition = true, bool $force = false, string|Closure|array|null $action = TwoFactorPage::class)
public function enableTwoFactorAuthentication(bool $condition = true, Closure|bool $force = false, string|Closure|array|null $action = TwoFactorPage::class)
{
$this->twoFactorAuthentication = $condition;
$this->forceTwoFactorAuthentication = $force;
Expand All @@ -260,7 +260,7 @@ public function enableTwoFactorAuthentication(bool $condition = true, bool $forc

public function getForceTwoFactorAuthentication(): bool
{
return $this->forceTwoFactorAuthentication;
return $this->evaluate($this->forceTwoFactorAuthentication);
}

public function getTwoFactorRouteAction(): string|Closure|array|null
Expand Down Expand Up @@ -320,10 +320,10 @@ public function verify(string $code, ?Authenticatable $user = null)
public function shouldForceTwoFactor(): bool
{
if ($this->getCurrentPanel()->isEmailVerificationRequired()) {
return $this->forceTwoFactorAuthentication && ! $this->auth()->user()?->hasConfirmedTwoFactor() && $this->auth()->user()?->hasVerifiedEmail();
return $this->getForceTwoFactorAuthentication() && ! $this->auth()->user()?->hasConfirmedTwoFactor() && $this->auth()->user()?->hasVerifiedEmail();
}

return $this->forceTwoFactorAuthentication && ! $this->auth()->user()?->hasConfirmedTwoFactor();
return $this->getForceTwoFactorAuthentication() && ! $this->auth()->user()?->hasConfirmedTwoFactor();
}

public function enableSanctumTokens(bool $condition = true, ?array $permissions = null)
Expand Down

0 comments on commit 2d389fb

Please sign in to comment.