Skip to content

Commit 5a8710e

Browse files
committed
fix: corrected login via LDAP (#3319)
1 parent 253cec2 commit 5a8710e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

phpmyfaq/src/phpMyFAQ/Auth/AuthLdap.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ public function __construct(Configuration $configuration)
7171
*/
7272
public function create(string $login, #[SensitiveParameter] string $password, string $domain = ''): bool
7373
{
74+
$result = false;
7475
$user = new User($this->configuration);
75-
$result = $user->createUser($login, '', $domain);
76+
77+
try {
78+
$result = $user->createUser($login, '', $domain);
79+
} catch (\Exception $e) {
80+
$this->configuration->getLogger()->info($e->getMessage());
81+
}
7682

7783
$this->connect($this->activeServer);
7884

phpmyfaq/src/phpMyFAQ/User/CurrentUser.php

+16
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public function login(string $login, string $password): bool
147147
}
148148

149149
// Attempt to authenticate user by login and password
150+
$this->authContainer = $this->sortAuthContainer($this->authContainer);
150151
foreach ($this->authContainer as $authSource => $auth) {
151152
if (!$this->checkAuth($auth)) {
152153
continue; // Skip invalid Auth objects
@@ -753,4 +754,19 @@ protected function isFailedLastLoginAttempt(): bool
753754
$result = $this->configuration->getDb()->query($select);
754755
return $this->configuration->getDb()->numRows($result) !== 0;
755756
}
757+
758+
protected function sortAuthContainer(array $authContainer): array
759+
{
760+
uksort($authContainer, function ($a, $b) {
761+
if ($a === 'local') {
762+
return 1;
763+
}
764+
if ($b === 'local') {
765+
return -1;
766+
}
767+
return 0;
768+
});
769+
770+
return $authContainer;
771+
}
756772
}

0 commit comments

Comments
 (0)