41 lines
1.2 KiB
PHP
41 lines
1.2 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' => 'bj10sx',
|
|
'ylenaour' => 'bzh4231*',
|
|
'altisys' => 'fortest',
|
|
'oseo' => 'oseo',
|
|
);
|
|
|
|
//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);
|
|
}
|
|
|
|
}
|
|
} |