diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-09-01 02:48:54 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-09-01 02:50:27 +0200 |
commit | 3dacf149de2ac560328242666473533c81c4b418 (patch) | |
tree | 4991c802bb82d5be6572eec64cc7128548a8d646 /lib/user.php | |
parent | f67aef608f7bbeb43be2c8d8c10dc91ea0cb5d4b (diff) | |
download | nextcloud-server-3dacf149de2ac560328242666473533c81c4b418.tar.gz nextcloud-server-3dacf149de2ac560328242666473533c81c4b418.zip |
allow configuring user backends in config.php
Diffstat (limited to 'lib/user.php')
-rw-r--r-- | lib/user.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/user.php b/lib/user.php index c432f6074a6..305fb8ed3a2 100644 --- a/lib/user.php +++ b/lib/user.php @@ -39,6 +39,8 @@ class OC_User { // The backend used for user management private static $_usedBackends = array(); + + private static $_setupedBackends = array(); // Backends available (except database) private static $_backends = array(); @@ -115,6 +117,28 @@ class OC_User { } /** + * setup the configured backends in config.php + */ + public static function setupBackends(){ + $backends=OC_Config::getValue('user_backends',array()); + foreach($backends as $i=>$config){ + $class=$config['class']; + $arguments=$config['arguments']; + if(class_exists($class) and array_search($i,self::$_setupedBackends)===false){ + // make a reflection object + $reflectionObj = new ReflectionClass($class); + + // use Reflection to create a new instance, using the $args + $backend = $reflectionObj->newInstanceArgs($arguments); + self::useBackend($backend); + $_setupedBackends[]=$i; + }else{ + OC_Log::write('core','User backend '.$class.' not found.',OC_Log::ERROR); + } + } + } + + /** * @brief Create a new user * @param $uid The username of the user to create * @param $password The password of the new user @@ -253,6 +277,7 @@ class OC_User { public static function isLoggedIn(){ if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) { OC_App::loadApps(array('authentication')); + self::setupBackends(); if (self::userExists($_SESSION['user_id']) ){ return true; } |