Skip to content

Commit

Permalink
fix isLdapDeletedUser calls with null user
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Dec 8, 2023
1 parent 5111947 commit 679c111
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public function code(string $state = '', string $code = '', string $scope = '',
$this->ldapService->syncUser($userId);
// when auto provision is disabled, we assume the user has been created by another user backend (or manually)
$userFromOtherBackend = $this->userManager->get($userId);
if ($this->ldapService->isLdapDeletedUser($userFromOtherBackend)) {
if ($userFromOtherBackend !== null && $this->ldapService->isLdapDeletedUser($userFromOtherBackend)) {
$userFromOtherBackend = null;
}

Expand Down
2 changes: 0 additions & 2 deletions lib/Service/ProvisioningService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use OCP\User\Events\UserChangedEvent;

class ProvisioningService {
Expand Down
4 changes: 2 additions & 2 deletions lib/User/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function getCurrentUserId(): string {
$this->ldapService->syncUser($tokenUserId);
}
$userFromOtherBackend = $this->userManager->get($tokenUserId);
if ($this->ldapService->isLdapDeletedUser($userFromOtherBackend)) {
if ($userFromOtherBackend !== null && $this->ldapService->isLdapDeletedUser($userFromOtherBackend)) {
$userFromOtherBackend = null;
}

Expand Down Expand Up @@ -314,7 +314,7 @@ public function getCurrentUserId(): string {
}

$user = $this->userManager->get($tokenUserId);
if ($this->ldapService->isLdapDeletedUser($user)) {
if ($user === null || $this->ldapService->isLdapDeletedUser($user)) {
return '';
}
$this->checkFirstLogin($tokenUserId);
Expand Down

0 comments on commit 679c111

Please sign in to comment.