2010-09-13 09:00:36 +00:00
|
|
|
<?php
|
2010-11-29 10:57:12 +00:00
|
|
|
require_once 'framework/fwk.php';
|
|
|
|
require_once 'framework/common/mysql.php';
|
2010-09-13 09:00:36 +00:00
|
|
|
|
|
|
|
class WebAuthAdapter implements Zend_Auth_Adapter_Interface
|
|
|
|
{
|
|
|
|
protected $_username;
|
|
|
|
protected $_password;
|
|
|
|
|
|
|
|
public function __construct($username,$password)
|
|
|
|
{
|
|
|
|
$this->_username = $username;
|
|
|
|
$this->_password = $password;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function authenticate()
|
|
|
|
{
|
2010-12-07 09:38:41 +00:00
|
|
|
//return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_username);
|
2010-11-29 10:57:12 +00:00
|
|
|
$iDbCrm = new WDB('sdv1');
|
|
|
|
$rep = $iDbCrm->select(//'utilisateurs', 'login, id, email, password, idClient, typeCompte, filtre_ip, civilite, nom, prenom, tel, fax, mobile, profil, raisonSociale, siret, adrNum, adrIndRep, adrTypeVoie, adrLibVoie, adrCp, adrVille, adrComp, tel, fax, mobile, pref, profil, dateInscription, dateValidation, nombreConnexions, dateDerniereConnexion, droits, referenceParDefaut, nbReponses, formatMail, dateDebutCompte, dateFinCompte, maxFicheId', "login='$login' AND actif=1", true, MYSQL_ASSOC);
|
|
|
|
'utilisateurs u, clients c',
|
|
|
|
'u.login, u.id, u.email, u.password, u.idClient, u.typeCompte, u.actif, u.filtre_ip, u.civilite, u.nom, u.prenom, u.tel, u.fax, u.mobile, u.profil, u.raisonSociale, u.siret, u.adrNum, u.adrIndRep, u.adrTypeVoie, u.adrLibVoie, u.adrCp, u.adrVille, u.adrComp, u.tel, u.fax, u.mobile, u.pref, u.profil, u.dateInscription, u.dateValidation, u.nombreConnexions, u.dateDerniereConnexion, u.droits, u.referenceParDefaut, u.nbReponses, u.formatMail, u.dateDebutCompte, u.dateFinCompte, u.maxFicheId, c.droits AS droitsClients, c.timeout',
|
|
|
|
"u.login='$this->_username' AND u.idClient=c.id AND u.actif=1 AND u.deleted=0 AND c.actif='Oui'",
|
|
|
|
true, MYSQL_ASSOC);
|
|
|
|
$tabRep = $rep[0];
|
2010-09-13 09:00:36 +00:00
|
|
|
|
2010-11-29 10:57:12 +00:00
|
|
|
if (count($rep)==0){
|
|
|
|
//debugLog('W',"CheckAuth $login/$password inexistant ou inactif (IP=$ipConnexion)", __LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
2010-09-13 09:00:36 +00:00
|
|
|
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $this->_username);
|
|
|
|
} else {
|
2010-11-29 10:57:12 +00:00
|
|
|
if ( $tabRep['password']==$this->_password ){
|
|
|
|
//debugLog('W',"CheckAuth $login/$password OK", __LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_username);
|
|
|
|
} else {
|
|
|
|
//debugLog('W',"CheckAuth $login/$password incorrect (IP=$ipConnexion)", __LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $this->_username);
|
|
|
|
}
|
2010-09-13 09:00:36 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-29 10:57:12 +00:00
|
|
|
|
2010-09-13 09:00:36 +00:00
|
|
|
}
|