summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php11
-rw-r--r--lib/user.php25
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/base.php b/lib/base.php
index 8d605e52802..fb83f6ea0a4 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -351,6 +351,9 @@ class OC{
}
}
+ //setup extra user backends
+ OC_User::setupBackends();
+
// register cache cleanup jobs
OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
@@ -423,6 +426,7 @@ class OC{
// Someone is logged in :
if(OC_User::isLoggedIn()) {
OC_App::loadApps();
+ OC_User::setupBackends();
if(isset($_GET["logout"]) and ($_GET["logout"])) {
OC_User::logout();
header("Location: ".OC::$WEBROOT.'/');
@@ -469,7 +473,7 @@ class OC{
}
protected static function handleLogin() {
- OC_App::loadApps(array('prelogin','authentication'));
+ OC_App::loadApps(array('prelogin'));
$error = false;
// remember was checked after last login
if (OC::tryRememberLogin()) {
@@ -517,7 +521,12 @@ class OC{
|| ($_SESSION['sectoken']!=$_POST['sectoken']) ) {
return false;
}
+
OC_App::loadApps();
+
+ //setup extra user backends
+ OC_User::setupBackends();
+
if(OC_User::login($_POST["user"], $_POST["password"])) {
if(!empty($_POST["remember_login"])){
if(defined("DEBUG") && DEBUG) {
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;
}