Event Service

This commit is contained in:
Eric
2020-05-15 20:42:05 +02:00
parent 7e970ee93c
commit 8bfc54e6b4
20 changed files with 1364 additions and 25 deletions

View File

@@ -24,6 +24,9 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Service\Event;
use Combodo\iTop\Service\EventName;
/**
* Web page used for displaying the login form
*/
@@ -447,6 +450,7 @@ class LoginWebPage extends NiceWebPage
$_SESSION['login_state'] = self::LOGIN_STATE_START;
}
$sLoginState = $_SESSION['login_state'];
$bFireEvent = ($sLoginState != self::LOGIN_STATE_CONNECTED);
$sSessionLog = '';
if ($bLoginDebug)
@@ -487,10 +491,15 @@ class LoginWebPage extends NiceWebPage
$iResponse = $oLoginFSMExtensionInstance->LoginAction($sLoginState, $iErrorCode);
if ($iResponse == self::LOGIN_FSM_RETURN)
{
if ($bFireEvent)
{
Event::FireEvent(EventName::LOGIN, null, array('code' => $iErrorCode, 'state' => $sLoginState));
}
return $iErrorCode; // Asked to exit FSM, generally login OK
}
if ($iResponse == self::LOGIN_FSM_ERROR)
{
Event::FireEvent(EventName::LOGIN, null, array('code' => $iErrorCode, 'state' => $sLoginState));
$sLoginState = self::LOGIN_STATE_SET_ERROR; // Next state will be error
// An error was detected, skip the other plugins turn
break;
@@ -504,6 +513,7 @@ class LoginWebPage extends NiceWebPage
}
catch (Exception $e)
{
Event::FireEvent(EventName::LOGIN, null, array('state' => $_SESSION['login_state']));
IssueLog::Error($e->getTraceAsString());
static::ResetSession();
die($e->getMessage());