Skip to content

Commit

Permalink
Fix Nextcloud bug with backend synchronisation
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrupp committed Sep 7, 2018
1 parent f5fa4a9 commit abf4ac2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/Hooks/UserHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,20 @@ public function preLogin($uid, $password)
$this->loggingService->write(\OCP\Util::DEBUG, 'phpCAS no new user has been created.');
}

// Don’t do that for Cextcloud
/** @var \OCP\Defaults $defaults */
$defaults = new \OCP\Defaults();

if (!is_null($oldUserObject) && ($oldUserObject->getBackendClassName() === "OC\\User\\Database" || $oldUserObject->getBackendClassName() === "Database")) {
if (strpos(strtolower($defaults->getName()), 'next') === FALSE) {

$query = \OC_DB::prepare('UPDATE `*PREFIX*accounts` SET `backend` = ? WHERE LOWER(`user_id`) = LOWER(?)');
$result = $query->execute([get_class($this->userService->getBackend()), $uid]);
if (!is_null($oldUserObject) && ($oldUserObject->getBackendClassName() === "OC\\User\\Database" || $oldUserObject->getBackendClassName() === "Database")) {

$this->loggingService->write(\OCP\Util::DEBUG, 'phpCAS user existing in database backend, move to CAS-Backend with result: ' . $result);
}
$query = \OC_DB::prepare('UPDATE `*PREFIX*accounts` SET `backend` = ? WHERE LOWER(`user_id`) = LOWER(?)');
$result = $query->execute([get_class($this->userService->getBackend()), $uid]);

$this->loggingService->write(\OCP\Util::DEBUG, 'phpCAS user existing in database backend, move to CAS-Backend with result: ' . $result);
}
}
}
}
} else {
Expand Down

0 comments on commit abf4ac2

Please sign in to comment.