logout wait

This commit is contained in:
Yuri Kuznetsov
2023-01-23 15:31:38 +02:00
parent d655ee92a2
commit 8224eec990
4 changed files with 24 additions and 2 deletions

View File

@@ -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<string, array<string, mixed>> $map */

View File

@@ -0,0 +1 @@
<div></div>

View File

@@ -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();

View File

@@ -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();
},