diff --git a/controllers/SSOCommon.php b/controllers/SSOCommon.php index e5a776d6..d03dc146 100644 --- a/controllers/SSOCommon.php +++ b/controllers/SSOCommon.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2023 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -141,14 +141,15 @@ public static function setupSSOByAccount($account) { } return $retval; } - + public static function setupSSOByName($account, $name) { - $retval = false; - $row = Engine::api(IUser::class)->getUserByFullname($name); - if($row) { - Engine::api(IUser::class)->assignAccount($row["name"], $account); - $retval = self::setupSSOByAccount($account); - } - return $retval; + $api = Engine::api(IUser::class); + $row = $api->getUserByFullname($name); + if($row) + $api->assignAccount($row["name"], $account); + else + $api->createNewAccount($name, $account); + + return self::setupSSOByAccount($account); } } diff --git a/engine/impl/User.php b/engine/impl/User.php index 247fa97a..68356014 100644 --- a/engine/impl/User.php +++ b/engine/impl/User.php @@ -3,7 +3,7 @@ * Zookeeper Online * * @author Jim Mason - * @copyright Copyright (C) 1997-2022 Jim Mason + * @copyright Copyright (C) 1997-2024 Jim Mason * @link https://zookeeper.ibinx.com/ * @license GPL-3.0 * @@ -50,7 +50,7 @@ public function getUserByAccount($account) { } public function getUserByFullname($fullname) { - $query = "SELECT * FROM users WHERE realname = ?"; + $query = "SELECT * FROM users WHERE realname = ? AND ssoaccount IS NULL"; $stmt = $this->prepare($query); $stmt->bindValue(1, $fullname); return $stmt->executeAndFetch();