From a9ede731f522c0a09d06cbd5ded0c2c928bc4b7e Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 24 Oct 2016 09:48:19 +0200 Subject: [PATCH] CS --- .../Application/Controller/Plugin/Auth.php | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/library/Application/Controller/Plugin/Auth.php b/library/Application/Controller/Plugin/Auth.php index a6741f9a..641d51b0 100644 --- a/library/Application/Controller/Plugin/Auth.php +++ b/library/Application/Controller/Plugin/Auth.php @@ -47,19 +47,15 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract // --- On vérifie le tout lors d'une connexion par url if ( !empty($login) && !empty($pass) ) { - $authAdapter = new Scores_Auth_Adapter_Db($login, $pass, $checkWs); $result = $auth->authenticate($authAdapter); - if ($result->isValid()) { - $storage = new Zend_Auth_Storage_Session(); $session = new Zend_Session_Namespace($storage->getNamespace()); //$session->setExpirationSeconds(86400); $auth->setStorage($storage); - - } else { - + } + else { $layout = Zend_Layout::getMVCInstance(); if ( !$layout->isEnabled() ){ echo "Identification incorrect ou périmé."; @@ -68,29 +64,24 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract ->setControllerName('user') ->setActionName('logout'); } - } - - //Sinon on reste sur le standard - } else { - - //Pas authentifié + } + // Sinon on reste sur le standard + else { + // Pas authentifié if ( !$auth->hasIdentity() || time() > $auth->getIdentity()->time ) { - $layout = Zend_Layout::getMVCInstance(); if (!$layout->isEnabled()){ echo "Identification incorrect ou périmé."; } else { $this->_response->setRedirect('/user/login')->sendResponse(); } - - //Authentifié => on met à jour la session - } else { - + } + // Authentifié => on met à jour la session + else { $identity = $auth->getIdentity(); $identity->time = time() + $identity->timeout; $auth->getStorage()->write($identity); - } } }