From 44aa24bab16bdc2545b08594386adb24ead3aa9e Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 9 Nov 2017 15:09:54 -0800 Subject: Add user backend provider system --- app/Model/UserModel.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/Model') 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; + } } -- cgit v1.2.3