use BookStack\Auth\Access\LdapService;
use BookStack\Auth\Access\RegistrationService;
use BookStack\Auth\User;
+use BookStack\Exceptions\JsonDebugException;
use BookStack\Exceptions\LdapException;
use BookStack\Exceptions\LoginAttemptEmailNeededException;
use BookStack\Exceptions\LoginAttemptException;
class LdapSessionGuard extends ExternalBaseSessionGuard
{
- protected $ldapService;
+ protected LdapService $ldapService;
/**
* LdapSessionGuard constructor.
* @param array $credentials
* @param bool $remember
*
+ * @throws LdapException*@throws \BookStack\Exceptions\JsonDebugException
* @throws LoginAttemptException
- * @throws LdapException
+ * @throws JsonDebugException
*
* @return bool
*/
try {
$user = $this->createNewFromLdapAndCreds($userDetails, $credentials);
} catch (UserRegistrationException $exception) {
- throw new LoginAttemptException($exception->message);
+ throw new LoginAttemptException($exception->getMessage());
}
}
}
// Attach avatar if non-existent
- if (is_null($user->avatar)) {
+ if (!$user->avatar()->exists()) {
$this->ldapService->saveAndAttachAvatar($user, $userDetails);
}