FIX restore security event login/logout
This commit is contained in:
parent
cf74e5b9a8
commit
3f912ebfff
@ -76,9 +76,9 @@ class Events // extends CommonObject
|
|||||||
|
|
||||||
// List of all Audit/Security events supported by triggers
|
// List of all Audit/Security events supported by triggers
|
||||||
public $eventstolog=array(
|
public $eventstolog=array(
|
||||||
/*array('id'=>'USER_LOGIN', 'test'=>1),
|
array('id'=>'USER_LOGIN', 'test'=>1),
|
||||||
array('id'=>'USER_LOGIN_FAILED', 'test'=>1),
|
array('id'=>'USER_LOGIN_FAILED', 'test'=>1),
|
||||||
array('id'=>'USER_LOGOUT', 'test'=>1),*/
|
array('id'=>'USER_LOGOUT', 'test'=>1),
|
||||||
array('id'=>'USER_CREATE', 'test'=>1),
|
array('id'=>'USER_CREATE', 'test'=>1),
|
||||||
array('id'=>'USER_MODIFY', 'test'=>1),
|
array('id'=>'USER_MODIFY', 'test'=>1),
|
||||||
array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
|
array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
|
||||||
|
|||||||
@ -70,7 +70,7 @@ class InterfaceLogevents extends DolibarrTriggers
|
|||||||
$date = dol_now();
|
$date = dol_now();
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
/*if ($action == 'USER_LOGIN')
|
if ($action == 'USER_LOGIN')
|
||||||
{
|
{
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class InterfaceLogevents extends DolibarrTriggers
|
|||||||
// Initialisation donnees (date,duree,texte,desc)
|
// Initialisation donnees (date,duree,texte,desc)
|
||||||
$text="(UserLogoff,".$object->login.")";
|
$text="(UserLogoff,".$object->login.")";
|
||||||
$desc="(UserLogoff,".$object->login.")";
|
$desc="(UserLogoff,".$object->login.")";
|
||||||
}*/
|
}
|
||||||
if ($action == 'USER_CREATE')
|
if ($action == 'USER_CREATE')
|
||||||
{
|
{
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|||||||
@ -500,6 +500,17 @@ if (! defined('NOLOGIN'))
|
|||||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadValueForCode");
|
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadValueForCode");
|
||||||
$test=false;
|
$test=false;
|
||||||
|
|
||||||
|
// Call trigger for the "security events" log
|
||||||
|
$user->trigger_mesg='ErrorBadValueForCode - login='.GETPOST("username","alpha",2);
|
||||||
|
// Call of triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($db);
|
||||||
|
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End Call of triggers
|
||||||
|
|
||||||
// Hooks on failed login
|
// Hooks on failed login
|
||||||
$action='';
|
$action='';
|
||||||
$hookmanager->initHooks(array('login'));
|
$hookmanager->initHooks(array('login'));
|
||||||
@ -568,6 +579,17 @@ if (! defined('NOLOGIN'))
|
|||||||
// We set a generic message if not defined inside function checkLoginPassEntity or subfunctions
|
// We set a generic message if not defined inside function checkLoginPassEntity or subfunctions
|
||||||
if (empty($_SESSION["dol_loginmesg"])) $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
|
if (empty($_SESSION["dol_loginmesg"])) $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
|
||||||
|
|
||||||
|
// Call trigger for the "security events" log
|
||||||
|
$user->trigger_mesg=$langs->trans("ErrorBadLoginPassword").' - login='.GETPOST("username","alpha",2);
|
||||||
|
// Call of triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($db);
|
||||||
|
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,GETPOST("username","alpha",2));
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End Call of triggers
|
||||||
|
|
||||||
// Hooks on failed login
|
// Hooks on failed login
|
||||||
$action='';
|
$action='';
|
||||||
$hookmanager->initHooks(array('login'));
|
$hookmanager->initHooks(array('login'));
|
||||||
@ -604,12 +626,25 @@ if (! defined('NOLOGIN'))
|
|||||||
$langs->loadLangs(array('main', 'errors'));
|
$langs->loadLangs(array('main', 'errors'));
|
||||||
|
|
||||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
|
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
|
||||||
|
|
||||||
|
$user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
|
||||||
}
|
}
|
||||||
if ($resultFetchUser < 0)
|
if ($resultFetchUser < 0)
|
||||||
{
|
{
|
||||||
$_SESSION["dol_loginmesg"]=$user->error;
|
$_SESSION["dol_loginmesg"]=$user->error;
|
||||||
|
|
||||||
|
$user->trigger_mesg=$user->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call triggers for the "security events" log
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($db);
|
||||||
|
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
// Hooks on failed login
|
// Hooks on failed login
|
||||||
$action='';
|
$action='';
|
||||||
$hookmanager->initHooks(array('login'));
|
$hookmanager->initHooks(array('login'));
|
||||||
@ -648,12 +683,25 @@ if (! defined('NOLOGIN'))
|
|||||||
$langs->loadLangs(array('main', 'errors'));
|
$langs->loadLangs(array('main', 'errors'));
|
||||||
|
|
||||||
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
|
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorCantLoadUserFromDolibarrDatabase",$login);
|
||||||
|
|
||||||
|
$user->trigger_mesg='ErrorCantLoadUserFromDolibarrDatabase - login='.$login;
|
||||||
}
|
}
|
||||||
if ($resultFetchUser < 0)
|
if ($resultFetchUser < 0)
|
||||||
{
|
{
|
||||||
$_SESSION["dol_loginmesg"]=$user->error;
|
$_SESSION["dol_loginmesg"]=$user->error;
|
||||||
|
|
||||||
|
$user->trigger_mesg=$user->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call triggers for the "security events" log
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($db);
|
||||||
|
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
// Hooks on failed login
|
// Hooks on failed login
|
||||||
$action='';
|
$action='';
|
||||||
$hookmanager->initHooks(array('login'));
|
$hookmanager->initHooks(array('login'));
|
||||||
@ -741,6 +789,17 @@ if (! defined('NOLOGIN'))
|
|||||||
|
|
||||||
$loginfo = 'TZ='.$_SESSION["dol_tz"].';TZString='.$_SESSION["dol_tz_string"].';Screen='.$_SESSION["dol_screenwidth"].'x'.$_SESSION["dol_screenheight"];
|
$loginfo = 'TZ='.$_SESSION["dol_tz"].';TZString='.$_SESSION["dol_tz_string"].';Screen='.$_SESSION["dol_screenwidth"].'x'.$_SESSION["dol_screenheight"];
|
||||||
|
|
||||||
|
// Call triggers for the "security events" log
|
||||||
|
$user->trigger_mesg = $loginfo;
|
||||||
|
// Call triggers
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
|
$interface=new Interfaces($db);
|
||||||
|
$result=$interface->run_triggers('USER_LOGIN',$user,$user,$langs,$conf);
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
// End call triggers
|
||||||
|
|
||||||
// Hooks on successfull login
|
// Hooks on successfull login
|
||||||
$action='';
|
$action='';
|
||||||
$hookmanager->initHooks(array('login'));
|
$hookmanager->initHooks(array('login'));
|
||||||
@ -752,7 +811,7 @@ if (! defined('NOLOGIN'))
|
|||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
dol_print_error($db,'Error in some hooks afterLogin');
|
dol_print_error($db,'Error in some triggers USER_LOGIN or in some hooks afterLogin');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -41,13 +41,12 @@ if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuse
|
|||||||
|
|
||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
|
|
||||||
// Appel des triggers
|
// Call triggers for the "security events" log
|
||||||
// TODO @deprecated Remove this. Hook must be used, not this trigger.
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
$interface=new Interfaces($db);
|
||||||
//$interface=new Interfaces($db);
|
$result=$interface->run_triggers('USER_LOGOUT',$user,$user,$langs,$conf);
|
||||||
//$result=$interface->run_triggers('USER_LOGOUT',$user,$user,$langs,$conf);
|
if ($result < 0) { $error++; }
|
||||||
//if ($result < 0) { $error++; }
|
// End call triggers
|
||||||
// Fin appel triggers
|
|
||||||
|
|
||||||
// Hooks on logout
|
// Hooks on logout
|
||||||
$action='';
|
$action='';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user