Commit 8abd9b45 authored by Henri-Damien LAURENT's avatar Henri-Damien LAURENT
Browse files

hotline #143813 improve disconnection behavior

parent 1bede4ed
Pipeline #15159 failed with stage
in 20 minutes and 11 seconds
- ticket #143813 : Déconnexion : amélioration des performances de la déconnexion.
\ No newline at end of file
......@@ -59,7 +59,7 @@ class AuthController extends ZendAfi_Controller_Action {
public function getRedirectDefaultUrl() {
return $this->_request->getParam('redirect','/opac');
return $this->_request->getParam('redirect', '/opac');
}
......@@ -302,7 +302,13 @@ class AuthController extends ZendAfi_Controller_Action {
public function logoutAction() {
Class_Auth_Strategy::newFor($this)->logout();
$this->view->_redirect_url = $this->getRedirectDefaultUrl();
}
public function logoutOthersStrategiesAction() {
Class_Auth_Strategy::newFor($this)
->logout();
}
......
<?php
echo $this->renderLogout($this->_redirect_url);
......@@ -46,7 +46,6 @@ class Class_Auth_IdentityProviderLogged extends Class_Auth_Logged {
$redirect_url = $provider->logoutUrl($this->_getProfilRedirectUrl());
$provider->clearRemoteLogin();
ZendAfi_Auth::getInstance()->clearIdentity();
$this->controller->redirect($redirect_url);
}
......
......@@ -80,7 +80,6 @@ abstract class Class_Auth_Strategy {
public function logout() {
ZendAfi_Auth::getInstance()->clearIdentity();
(new Class_IdentityProvider_Types)->clearRemoteLogin();
$this->controller->redirect($this->_getProfilRedirectUrl());
}
......
......@@ -128,6 +128,11 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action {
}
public function sessionWriteClose() {
session_write_close();
}
protected function _redirect($url, array $options = array()) {
if ($this->isPopupRequest() && $this->_request->isPost()) {
$this
......
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_RenderLogout extends ZendAfi_View_Helper_BaseHelper {
public function renderLogout($redirect_url) {
$others_logouts = sprintf('$.ajax("%s")',
$this->view->url(['module' => 'opac',
'controller' => 'auth',
'action' => 'logout-others-strategies'],
null,
true));
$redirect = $redirect_url
? sprintf('location.href = "%s"', $redirect_url)
: 'location.reload()';
$script_loader = Class_ScriptLoader::newInstance()
->addJQueryReady(sprintf('%s; setTimeout(function() {%s;}, 10);',
$others_logouts,
$redirect));
ZendAfi_Auth::getInstance()->clearIdentity();
session_write_close();
return $script_loader->html()
. $this->_tag('div',
$this->_tag('p',
$this->_('Déconnection en cours…'))
. $this->view->tagLoadingImg(),
['class' => 'saving-process text-center']);
}
}
<?php
/**
* Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class AuthControllerLogoutDispatchTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->dispatch('/auth/logout');
}
/** @test */
public function responseShouldContainsAjaxLoadToAuthLogoutOthersStrategies() {
$this->assertXPathContentContains('//script', '$(function(){$.ajax("/auth/logout-others-strategies"); ');
}
/** @test */
public function responseShouldContainsRedirectToOpac() {
$this->assertXPathContentContains('//script', 'setTimeout(function() {location.href = "/opac";}, 10);');
}
/** @test */
public function responseShouldMessageDisconnecting() {
$this->assertXPathContentContains('//div[@class="saving-process text-center"]/p', 'Déconnection en cours…');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment