Add possibility to include login method in a module
This commit is contained in:
parent
4060369420
commit
b5333b5567
@ -332,6 +332,16 @@ if (! defined('NOLOGIN'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validation of third party module login method
|
||||||
|
if (is_array($conf->login_method_modules) && !empty($conf->login_method_modules))
|
||||||
|
{
|
||||||
|
$login = getLoginMethod();
|
||||||
|
if ($login)
|
||||||
|
{
|
||||||
|
$test=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Validation tests user / password
|
// Validation tests user / password
|
||||||
// If ok, the variable will be initialized login
|
// If ok, the variable will be initialized login
|
||||||
// If error, we will put error message in session under the name dol_loginmesg
|
// If error, we will put error message in session under the name dol_loginmesg
|
||||||
@ -1233,6 +1243,57 @@ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch='search',$
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of login method of third party module.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getLoginMethod()
|
||||||
|
{
|
||||||
|
global $conf,$langs;
|
||||||
|
|
||||||
|
$login = '';
|
||||||
|
|
||||||
|
foreach($conf->login_method_modules as $dir)
|
||||||
|
{
|
||||||
|
// Check if directory exists
|
||||||
|
if (!is_dir($dir)) continue;
|
||||||
|
|
||||||
|
$handle=opendir($dir);
|
||||||
|
|
||||||
|
while (($file = readdir($handle))!==false)
|
||||||
|
{
|
||||||
|
if (is_readable($dir.'/'.$file) && preg_match('/^functions_([^_]+)\.php/',$file,$reg))
|
||||||
|
{
|
||||||
|
$authfile = $dir.'/'.$file;
|
||||||
|
$mode = $reg[1];
|
||||||
|
|
||||||
|
$result=include_once($authfile);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
// Call function to check user/password
|
||||||
|
$usertotest=$_POST["username"];
|
||||||
|
$passwordtotest=$_POST["password"];
|
||||||
|
$function='check_user_password_'.$mode;
|
||||||
|
$login=$function($usertotest,$passwordtotest);
|
||||||
|
if ($login)
|
||||||
|
{
|
||||||
|
$conf->authmode=$mode; // This properties is defined only when logged
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_syslog("Authentification ko - failed to load file '".$authfile."'",LOG_ERR);
|
||||||
|
sleep(1);
|
||||||
|
$langs->load('main');
|
||||||
|
$langs->load('other');
|
||||||
|
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorFailedToLoadLoginFileForMode",$mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
return $login;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Show HTML footer DIV + BODY + HTML
|
* \brief Show HTML footer DIV + BODY + HTML
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user