Skip to content

Commit

Permalink
Merge pull request #210 from creative-commoners/pulls/4.0/disable-mfa…
Browse files Browse the repository at this point in the history
…-without-methods

FIX No longer redirects to MFA when no methods are installed on the system
  • Loading branch information
NightJar committed Jun 24, 2019
2 parents 5784419 + a2dc9ff commit a91ebbe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Service/EnforcementManager.php
Expand Up @@ -100,6 +100,10 @@ public function shouldRedirectToMFA(Member $member): bool
return false;
}

if (empty(MethodRegistry::singleton()->getMethods())) {
return false;
}

if ($member->RegisteredMFAMethods()->exists()) {
return true;
}
Expand Down
12 changes: 12 additions & 0 deletions tests/php/Service/EnforcementManagerTest.php
Expand Up @@ -153,6 +153,18 @@ public function testShouldNotRedirectToMFAWhenConfigIsDisabled()
$this->assertFalse($shouldRedirect);
}

public function testShouldNotRedirectToMFAWhenNoMethodsAreRegisteredInTheSystem()
{
$this->setSiteConfig(['MFARequired' => true]);
MethodRegistry::config()->set('methods', []);

/** @var Member $member */
$member = $this->objFromFixture(Member::class, 'sally_smith');
$this->logInAs($member);

$this->assertFalse(EnforcementManager::create()->shouldRedirectToMFA($member));
}

/**
* Helper method for changing the current SiteConfig values
*
Expand Down

0 comments on commit a91ebbe

Please sign in to comment.