53 lines
1.8 KiB
PHP
53 lines
1.8 KiB
PHP
<?php
|
|
class WebAuthAdapter implements Zend_Auth_Adapter_Interface
|
|
{
|
|
protected $_username;
|
|
protected $_password;
|
|
protected $_timeout = 1800;
|
|
|
|
public function __construct($username, $password, $iponly = false)
|
|
{
|
|
$this->_username = $username;
|
|
$this->_password = $password;
|
|
if ($iponly){
|
|
$this->_password = 'iponly:'.$_SERVER['REMOTE_ADDR'];
|
|
}
|
|
$this->_checkIp = false;
|
|
}
|
|
|
|
public function authenticate()
|
|
{
|
|
$adressIp = $_SERVER['REMOTE_ADDR'];
|
|
require_once 'Scores/WsScores.php';
|
|
$ws = new WsScores($this->_username, $this->_password);
|
|
$InfosLogin = $ws->getInfosLogin($this->_username, $adressIp);
|
|
|
|
$identity = new stdClass;
|
|
$identity->username = $this->_username;
|
|
$identity->password = $this->_password;
|
|
$identity->email = $InfosLogin->result->email;
|
|
$identity->profil = $InfosLogin->result->profil;
|
|
$identity->pref = $InfosLogin->result->pref;
|
|
$identity->droits = $InfosLogin->result->droits;
|
|
$identity->nom = $InfosLogin->result->nom;
|
|
$identity->prenom = $InfosLogin->result->prenom;
|
|
$identity->id = $InfosLogin->result->id;
|
|
$identity->idClient = $InfosLogin->result->idClient;
|
|
$identity->reference = $InfosLogin->result->reference;
|
|
$identity->typeScore = $InfosLogin->result->typeScore;
|
|
$identity->timeout = (!empty($InfosLogin->result->timeout)) ?
|
|
$InfosLogin->result->timeout : $this->_timeout;
|
|
|
|
$logger = Zend_Registry::get('firebug');
|
|
$logger->log($identity, Zend_Log::DEBUG);
|
|
|
|
if ($InfosLogin->error->errnum!=0){
|
|
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity);
|
|
} elseif ($this->_username == $InfosLogin->result->login) {
|
|
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
|
|
} else {
|
|
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
|
|
}
|
|
}
|
|
|
|
} |