Skip to content

Commit

Permalink
Merge pull request #603 from DirectoryTree/BUG-602
Browse files Browse the repository at this point in the history
Bug 602 - LoginController::causedByInvalidCredentials(): Argument DirectoryTree/LdapRecord#2 ($diagnosticMessage) must be of type string #602
  • Loading branch information
stevebauman authored Nov 1, 2023
2 parents bd1cb18 + a0e791f commit bd7d2e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Auth/ListensForLdapBindFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ protected function ldapBindFailed(string $errorMessage, string $diagnosticMessag
$this->handleLdapBindError($errorMessage);

return;

case is_null($diagnosticMessage):
// If there is no diagnostic message to work with, we
// cannot make any further attempts to determine
// the error. We will bail here in such case.
return;

case $this->causedByInvalidCredentials($errorMessage, $diagnosticMessage):
// We'll bypass any invalid LDAP credential errors and let
// the login controller handle it. This is so proper
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/ListenForLdapBindFailureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function test_validation_exception_is_not_thrown_when_invalid_credentials

/** @var \LdapRecord\Testing\LdapFake $ldap */
$ldap = $fake->getLdapConnection();
$ldap->shouldReturnDiagnosticMessage(null);
$ldap->shouldReturnError('Invalid credentials');

$this->assertFalse($fake->auth()->attempt('user', 'secret'));
Expand Down

0 comments on commit bd7d2e0

Please sign in to comment.