getControllerName(); $action = $request->getActionName(); $checkAuth = true; // --- Pas d'authentification sur la demande d'authentification if ( $controller == 'user' && $action == 'login' ) { $checkAuth = false; } // --- Pas d'authentification sur ces services if ( in_array($controller, array('service', 'import')) || ( $controller == 'fichier' && $action == 'logs' ) || ( $controller == 'fichier' && $action == 'kbis' ) || ( $controller == 'fichier' && $action == 'csv' ) || ( $controller == 'fichier' && $action == 'associations' ) || ( $controller == 'fichier' && $action == 'greffes' ) || ( $controller == 'fichier' && $action == 'crm' )) { $checkAuth = false; } $checkWs = true; if ( $controller == 'fichier' ) { $checkWs = false; } if ($checkAuth) { $login = $request->getParam('login'); $pass = $request->getParam('pass', ''); $hach = $request->getParam('hach'); if (!empty($hach)) { $pass = $hach; } $auth = Zend_Auth::getInstance(); // --- 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 { $layout = Zend_Layout::getMVCInstance(); if ( !$layout->isEnabled() ){ echo "Identification incorrect ou périmé."; } else { $request->setModuleName('default') ->setControllerName('user') ->setActionName('logout'); } } //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 { $identity = $auth->getIdentity(); $identity->time = time() + $identity->timeout; $auth->getStorage()->write($identity); } } } } }