Skip to content

Commit b1af639

Browse files
authored
Merge pull request #1170 from nextcloud/fix/1169/soft-auto-prov-broken
Fix soft auto provisioning
2 parents aa97baa + 4332327 commit b1af639

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

lib/Controller/LoginController.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,25 +538,25 @@ public function code(string $state = '', string $code = '', string $scope = '',
538538
$this->ldapService->syncUser($userId);
539539
}
540540

541-
$userFromOtherBackend = $this->userManager->get($userId);
542-
if ($userFromOtherBackend !== null && $this->ldapService->isLdapDeletedUser($userFromOtherBackend)) {
543-
$userFromOtherBackend = null;
541+
$existingUser = $this->userManager->get($userId);
542+
if ($existingUser !== null && $this->ldapService->isLdapDeletedUser($existingUser)) {
543+
$existingUser = null;
544544
}
545545

546546
if ($autoProvisionAllowed) {
547-
if (!$softAutoProvisionAllowed && $userFromOtherBackend !== null) {
547+
if (!$softAutoProvisionAllowed && $existingUser !== null && $existingUser->getBackendClassName() !== Application::APP_ID) {
548548
// if soft auto-provisioning is disabled,
549549
// we refuse login for a user that already exists in another backend
550550
$message = $this->l10n->t('User conflict');
551551
return $this->build403TemplateResponse($message, Http::STATUS_BAD_REQUEST, ['reason' => 'non-soft auto provision, user conflict'], false);
552552
}
553553
// use potential user from other backend, create it in our backend if it does not exist
554-
$provisioningResult = $this->provisioningService->provisionUser($userId, $providerId, $idTokenPayload, $userFromOtherBackend);
554+
$provisioningResult = $this->provisioningService->provisionUser($userId, $providerId, $idTokenPayload, $existingUser);
555555
$user = $provisioningResult['user'];
556556
$this->session->set('user_oidc.oidcUserData', $provisioningResult['userData']);
557557
} else {
558558
// when auto provision is disabled, we assume the user has been created by another user backend (or manually)
559-
$user = $userFromOtherBackend;
559+
$user = $existingUser;
560560
}
561561

562562
if ($user === null) {

0 commit comments

Comments
 (0)