webservice/library/Web/WebAuthAdapter.php
2010-09-13 09:00:36 +00:00

38 lines
1.1 KiB
PHP

<?php
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()
{
//@todo faire une requête getInfosLogin
$usersPassword = array(
'mricois' => 'mricois',
);
//Login inexistant
if (!array_key_exists($this->_username, $usersPassword)) {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $this->_username);
//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, $this->_username);
//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, $this->_username);
//...
} else {
return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $this->_username);
}
}
}