Fixed not shown existing-email warning on new ldap user

- Reduced the amount of different exceptions from LDAP attempt so they
can be handled more consistently.
- Added test to cover.
- Also cleaned up LDAP tests to reduce boilterplate mocks.

Fixes #2048
This commit is contained in:
Dan Brown
2020-04-26 12:13:00 +01:00
parent 468fec80de
commit 8ce38d2158
3 changed files with 66 additions and 84 deletions

View File

@ -60,10 +60,8 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
* @param array $credentials
* @param bool $remember
* @return bool
* @throws LoginAttemptEmailNeededException
* @throws LoginAttemptException
* @throws LdapException
* @throws UserRegistrationException
*/
public function attempt(array $credentials = [], $remember = false)
{
@ -82,7 +80,11 @@ class LdapSessionGuard extends ExternalBaseSessionGuard
}
if (is_null($user)) {
$user = $this->createNewFromLdapAndCreds($userDetails, $credentials);
try {
$user = $this->createNewFromLdapAndCreds($userDetails, $credentials);
} catch (UserRegistrationException $exception) {
throw new LoginAttemptException($exception->message);
}
}
// Sync LDAP groups if required

View File

@ -8,8 +8,6 @@ class NotifyException extends \Exception
/**
* NotifyException constructor.
* @param string $message
* @param string $redirectLocation
*/
public function __construct(string $message, string $redirectLocation = "/")
{