Amélioration de la gestion de l'authentification

This commit is contained in:
Michael RICOIS 2015-06-19 14:02:41 +00:00
parent d86685b235
commit f4ee5ee3b7
4 changed files with 79 additions and 78 deletions

View File

@ -632,9 +632,9 @@ class DashboardController extends Zend_Controller_Action
$request = $this->getRequest();
$infos = $request->getParams();
$ws = new WsScores();
$reponse = $ws->setClient($infos);
if ($reponse->error->errnum==1) {
$this->forward('client', 'dashboard', null, array('idClient' => $infos['idClient']));
$response = $ws->setClient($infos);
if (is_string($response) || $response === false) {
$this->forward('client', 'dashboard', 'default', array('idClient' => $infos['idClient']));
}
$this->view->assign('infos', $request->getParams());
}

View File

@ -415,8 +415,6 @@ class UserController extends Zend_Controller_Action
public function loginAction()
{
$this->_helper->layout()->disableLayout();
//@todo : gestion des affichages particuliers pour les clients
$this->view->headTitle()->append('Connexion');
$form = new Application_Form_Login();
$this->view->form = $form;
@ -428,7 +426,7 @@ class UserController extends Zend_Controller_Action
$pass = $form->getValue('pass');
$auth = Zend_Auth::getInstance();
$authAdapter = new Scores_Auth_Adapter_Ws($login, md5($login.'|'.$pass));
$authAdapter = new Scores_Auth_Adapter_Ws($login, $pass);
$result = $auth->authenticate($authAdapter);
//Auth is valid
@ -456,7 +454,6 @@ class UserController extends Zend_Controller_Action
}
//Auth error
else {
$this->view->message = '';
Zend_Registry::get('firebug')->info($result);
foreach ($result->getMessages() as $message) {

View File

@ -66,10 +66,15 @@ class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
require_once 'Scores/WsScores.php';
$ws = new WsScores($this->_username, $this->_password);
$InfosLogin = $ws->getInfosLogin($this->_username, $ip);
$InfosLogin = $ws->getInfosLogin($this->_username, $ip, 'auth');
// --- Renvoi
if ( is_string($InfosLogin) || $InfosLogin->error->errnum != 0 ) {
$message = $InfosLogin;
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array($message));
} elseif ( $InfosLogin !== false && !empty($InfosLogin->result->login)) {
$identity = new stdClass();
$identity->username = $this->_username;
$identity->password = $this->_password;
$identity->username = $InfosLogin->result->login;
$identity->password = md5($InfosLogin->result->login.'|'.$this->_password);
$identity->email = $InfosLogin->result->email;
$identity->profil = $InfosLogin->result->profil;
$identity->pref = $InfosLogin->result->pref;
@ -97,16 +102,12 @@ class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
$timeout = (!empty($InfosLogin->result->timeout)) ? $InfosLogin->result->timeout : $this->_timeout;
$identity->timeout = $timeout;
$identity->time = time() + $timeout;
$lang = in_array($InfosLogin->result->lang, array('fr','en')) ? $InfosLogin->result->lang : 'fr';
$identity->lang = $lang;
$identity->langtmp = $lang;
/*
* Adresse Ip interdites
*/
// --- Adresse Ip interdites
$ipInterdites =
'81.252.88.0-81.252.88.7' // CTE D AGGLOMERATION DE SOPHIA
. ';' . '195.200.187.163' // PacWan
@ -126,12 +127,11 @@ class Scores_Auth_Adapter_Ws implements Zend_Auth_Adapter_Interface
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
}
// Renvoi
if ( is_string($InfosLogin) || $InfosLogin->error->errnum != 0 ) {
$message = $InfosLogin;
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity, array($message));
} elseif ($this->_username == $InfosLogin->result->login) {
// --- OK connecté
$this->_username = $identity->username;
$this->_password = $identity->password;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
}

View File

@ -3181,9 +3181,12 @@ class WsScores
$reponse = $client->setClient($params);
return $reponse->setClientResult;
} catch (SoapFault $fault) {
if ( in_array($fault->faultcode, array('ERR', 'MSG')) ){
return $fault->faultstring;
} else {
$this->soaperror(__FUNCTION__, $fault, $client->__getLastRequest(), $client->__getLastResponse());
Zend_Registry::get('firebug')->info($fault);
//Placer exception pour affichage message
return false;
}
return false;
}
}
@ -3224,11 +3227,12 @@ class WsScores
* @param string $login
* @param string $ipUtilisateur
*/
public function getInfosLogin($login, $ipUtilisateur = '')
public function getInfosLogin($login, $ipUtilisateur = '', $from = null)
{
$params = new stdClass();
$params->login = $login;
$params->ipUtilisateur = $ipUtilisateur;
$params->from = $from;
try {
$client = $this->loadClient('gestion');
$reponse = $client->getInfosLogin($params);