Skip to content

Commit

Permalink
updated setupSSOByName to create new account if one does not already …
Browse files Browse the repository at this point in the history
…exist
  • Loading branch information
RocketMan committed Dec 4, 2024
1 parent 08e49bc commit 35d05b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions controllers/SSOCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions engine/impl/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2022 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 35d05b0

Please sign in to comment.