Skip to content
Snippets Groups Projects
Commit 4809fcf4 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch...

Merge branch 'hotline#138333_acces_a_cosmogramme_possible_avec_des_identifiants_d_administrateur_portail' into 'hotline'

hotline #138333 : fix cosmogramme login detection

See merge request !4121
parents 68578b10 cfc3345d
Branches
Tags
3 merge requests!4125master in,!4124hotline #138010 Search auto-complete : force locale fr_FR.UTF-8,!4121hotline #138333 : fix cosmogramme login detection
Pipeline #14060 passed with stage
in 47 minutes and 29 seconds
- ticket #138333 : Cosmogramme : Correction de la vérification de l'identification
\ No newline at end of file
<?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
*/
abstract class Cosmo_IdentityTestCase extends CosmoControllerTestCase {
public function setUp() {
parent::setUp();
$this->_prepareLogin()
->dispatch('/cosmo/annexe');
}
protected function _prepareLogin() {
return $this;
}
/** @test */
public function controllerShouldBeAuth() {
$this->assertEquals('auth', $this->_request->getControllerName());
}
/** @test */
public function actionShouldBeNotLogged() {
$this->assertEquals('not-logged', $this->_request->getActionName());
}
/** @test */
public function pageShouldContainsVousNEtesPlusConnecte() {
$this->assertXPathContentContains('//body', 'Vous n\'êtes plus connecté');
}
}
class Cosmo_IdentityNotLoggedTest extends Cosmo_IdentityTestCase {
protected function _prepareLogin() {
unset($_SESSION[Class_CosmoAuth::SESSION_KEY]);
return $this;
}
}
class Cosmo_IdentityFailedLoginTest extends Cosmo_IdentityTestCase {
protected function _prepareLogin() {
Class_CosmoAuth::fail();
return $this;
}
}
......@@ -57,6 +57,4 @@ if (!session_id())
// Controle login
if (isset($_REQUEST["action"]) && $_REQUEST['action'] == "logout") unset($_SESSION["passe"]);
if (!isset($_SESSION["passe"])) include("_identification.php");
?>
if (!Class_CosmoAuth::isLogged()) include("_identification.php");
......@@ -51,6 +51,16 @@ class Class_CosmoAuth {
}
public static function isLogged() {
return
isset($_SESSION[static::SESSION_KEY])
&& in_array($_SESSION[static::SESSION_KEY],
[static::ROLE_CATALOG,
static::ROLE_ADMIN,
static::ROLE_SYSTEM]);
}
public static function beSystem() {
return $_SESSION[static::SESSION_KEY] = static::ROLE_SYSTEM;
}
......@@ -72,6 +82,6 @@ class Class_CosmoAuth {
public static function fail() {
return $_SESSION[static::SESSION_KEY] = '';
return $_SESSION[static::SESSION_KEY] = null;
}
}
......@@ -16,7 +16,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
......@@ -26,10 +26,9 @@ class ZendAfi_Controller_Plugin_CosmoAuth extends Zend_Controller_Plugin_Abstrac
|| 'auth' == $request->getControllerName())
return;
if (!isset($_SESSION['passe'])) {
if (!Class_CosmoAuth::isLogged()) {
$request->setControllerName('auth');
$request->setActionName('not-logged');
}
}
}
?>
\ No newline at end of file
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