extranet/library/Web/WebAuthAdapter.php
2011-01-06 11:22:26 +00:00

43 lines
1.3 KiB
PHP

<?php
class WebAuthAdapter implements Zend_Auth_Adapter_Interface
{
protected $_username;
protected $_password;
protected $_timeout = 1800;
public function __construct($username,$password)
{
$this->_username = $username;
$this->_password = $password;
}
public function authenticate()
{
//@todo faire une requête getInfosLogin
$usersPassword = array(
'mricois' => 'bj10sx',
);
$identity = new stdClass();
$identity->username = $this->_username;
$identity->password = $this->_password;
$identity->timeout = $this->_timeout;
//Login inexistant
if (!array_key_exists($this->_username, $usersPassword)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $identity);
//Mot de pass incorrect
} elseif (array_key_exists($this->_username, $usersPassword) &&
$usersPassword[$this->_username] != $this->_password ) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $identity);
//Ok tout est bon
} elseif (array_key_exists($this->_username, $usersPassword) &&
$usersPassword[$this->_username] == $this->_password ) {
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $identity);
//...
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $identity);
}
}
}