diff --git a/application/Espo/Tools/App/AppService.php b/application/Espo/Tools/App/AppService.php index 2fc38f6042..547d1b51e3 100644 --- a/application/Espo/Tools/App/AppService.php +++ b/application/Espo/Tools/App/AppService.php @@ -130,7 +130,10 @@ class AppService $this->config->get('auth2FAForced') && !$user->get('auth2FA'); - $passwordChangeForNonAdminDisabled = $this->authenticationMethodProvider->get() !== Espo::NAME; + $authenticationMethod = $this->authenticationMethodProvider->get(); + + $passwordChangeForNonAdminDisabled = $authenticationMethod !== Espo::NAME; + $logoutWait = (bool) $this->metadata->get(['authenticationMethods', $authenticationMethod, 'logoutClassName']); $timeZoneList = $this->metadata ->get(['entityDefs', Settings::ENTITY_TYPE, 'fields', 'timeZone', 'options']) ?? []; @@ -141,6 +144,7 @@ class AppService 'passwordChangeForNonAdminDisabled' => $passwordChangeForNonAdminDisabled, 'timeZoneList' => $timeZoneList, 'auth2FARequired' => $auth2FARequired, + 'logoutWait' => $logoutWait, ]; /** @var array> $map */ diff --git a/client/res/templates/logout-wait.tpl b/client/res/templates/logout-wait.tpl new file mode 100644 index 0000000000..7c89b545c5 --- /dev/null +++ b/client/res/templates/logout-wait.tpl @@ -0,0 +1 @@ +
diff --git a/client/src/app.js b/client/src/app.js index 37d102e8a9..08ed9cb045 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -938,17 +938,25 @@ function ( * @private */ logout: function (afterFail, silent) { + let logoutWait = false; + if (this.auth && !afterFail) { let arr = Base64.decode(this.auth).split(':'); if (arr.length > 1) { + logoutWait = this.appParams.logoutWait || false; + Ajax.postRequest('App/action/destroyAuthToken', {token: arr[1]}, {fullResponse: true}) .then(xhr => { let redirectUrl = xhr.getResponseHeader('X-Logout-Redirect-Url'); if (redirectUrl) { setTimeout(() => window.location.href = redirectUrl, 50); + + return; } + + this.doAction({action: 'login'}); }); } } @@ -973,7 +981,9 @@ function ( this.storage.clear('user', 'anotherUser'); } - this.doAction({action: 'login'}); + let action = logoutWait ? 'logoutWait' : 'login'; + + this.doAction({action: action}); if (!silent) { this.unsetCookieAuth(); diff --git a/client/src/controllers/base.js b/client/src/controllers/base.js index 853202e088..a989dad7e9 100644 --- a/client/src/controllers/base.js +++ b/client/src/controllers/base.js @@ -133,6 +133,13 @@ define('controllers/base', ['controller'], function (Dep) { this.logout(); }, + actionLogoutWait: function () { + this.entire('views/base', {template: 'logout-wait'}, view => { + view.render() + .then(() => Espo.Ui.notify(' ... ')) + }); + }, + actionClearCache: function () { this.clearCache(); },