diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-11-09 15:09:54 -0800 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-11-09 15:09:54 -0800 |
commit | 44aa24bab16bdc2545b08594386adb24ead3aa9e (patch) | |
tree | 4ca2c4632d9657f8babfb7781b5aadc0d3e30238 /app/Model | |
parent | 95b2a36886a763242e11b4b27998a0d5c51ca7f4 (diff) |
Add user backend provider system
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/UserModel.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/Model/UserModel.php b/app/Model/UserModel.php index 56b1a960..af49ce7d 100644 --- a/app/Model/UserModel.php +++ b/app/Model/UserModel.php @@ -376,4 +376,20 @@ class UserModel extends Base ->eq('id', $user_id) ->save(array('token' => '')); } + + public function getOrCreateExternalUserId($username, $name, $externalIdColumn, $externalId) + { + $userId = $this->db->table(self::TABLE)->eq($externalIdColumn, $externalId)->findOneColumn('id'); + + if (empty($userId)) { + $userId = $this->create(array( + 'username' => $username, + 'name' => $name, + 'is_ldap_user' => 1, + $externalIdColumn => $externalId, + )); + } + + return $userId; + } } |