allow configuring user backends in config.php
This commit is contained in:
parent
f67aef608f
commit
3dacf149de
11
lib/base.php
11
lib/base.php
|
@ -351,6 +351,9 @@ class OC{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//setup extra user backends
|
||||||
|
OC_User::setupBackends();
|
||||||
|
|
||||||
// register cache cleanup jobs
|
// register cache cleanup jobs
|
||||||
OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
|
OC_BackgroundJob_RegularTask::register('OC_Cache_FileGlobal', 'gc');
|
||||||
OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
|
OC_Hook::connect('OC_User', 'post_login', 'OC_Cache_File', 'loginListener');
|
||||||
|
@ -423,6 +426,7 @@ class OC{
|
||||||
// Someone is logged in :
|
// Someone is logged in :
|
||||||
if(OC_User::isLoggedIn()) {
|
if(OC_User::isLoggedIn()) {
|
||||||
OC_App::loadApps();
|
OC_App::loadApps();
|
||||||
|
OC_User::setupBackends();
|
||||||
if(isset($_GET["logout"]) and ($_GET["logout"])) {
|
if(isset($_GET["logout"]) and ($_GET["logout"])) {
|
||||||
OC_User::logout();
|
OC_User::logout();
|
||||||
header("Location: ".OC::$WEBROOT.'/');
|
header("Location: ".OC::$WEBROOT.'/');
|
||||||
|
@ -469,7 +473,7 @@ class OC{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function handleLogin() {
|
protected static function handleLogin() {
|
||||||
OC_App::loadApps(array('prelogin','authentication'));
|
OC_App::loadApps(array('prelogin'));
|
||||||
$error = false;
|
$error = false;
|
||||||
// remember was checked after last login
|
// remember was checked after last login
|
||||||
if (OC::tryRememberLogin()) {
|
if (OC::tryRememberLogin()) {
|
||||||
|
@ -517,7 +521,12 @@ class OC{
|
||||||
|| ($_SESSION['sectoken']!=$_POST['sectoken']) ) {
|
|| ($_SESSION['sectoken']!=$_POST['sectoken']) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OC_App::loadApps();
|
OC_App::loadApps();
|
||||||
|
|
||||||
|
//setup extra user backends
|
||||||
|
OC_User::setupBackends();
|
||||||
|
|
||||||
if(OC_User::login($_POST["user"], $_POST["password"])) {
|
if(OC_User::login($_POST["user"], $_POST["password"])) {
|
||||||
if(!empty($_POST["remember_login"])){
|
if(!empty($_POST["remember_login"])){
|
||||||
if(defined("DEBUG") && DEBUG) {
|
if(defined("DEBUG") && DEBUG) {
|
||||||
|
|
25
lib/user.php
25
lib/user.php
|
@ -40,6 +40,8 @@ class OC_User {
|
||||||
// The backend used for user management
|
// The backend used for user management
|
||||||
private static $_usedBackends = array();
|
private static $_usedBackends = array();
|
||||||
|
|
||||||
|
private static $_setupedBackends = array();
|
||||||
|
|
||||||
// Backends available (except database)
|
// Backends available (except database)
|
||||||
private static $_backends = array();
|
private static $_backends = array();
|
||||||
|
|
||||||
|
@ -114,6 +116,28 @@ class OC_User {
|
||||||
self::$_usedBackends=array();
|
self::$_usedBackends=array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* @brief Create a new user
|
||||||
* @param $uid The username of the user to create
|
* @param $uid The username of the user to create
|
||||||
|
@ -253,6 +277,7 @@ class OC_User {
|
||||||
public static function isLoggedIn(){
|
public static function isLoggedIn(){
|
||||||
if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) {
|
if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) {
|
||||||
OC_App::loadApps(array('authentication'));
|
OC_App::loadApps(array('authentication'));
|
||||||
|
self::setupBackends();
|
||||||
if (self::userExists($_SESSION['user_id']) ){
|
if (self::userExists($_SESSION['user_id']) ){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue