tegi
ongelezen,27 okt 2010, 15:56:3127-10-2010Log in om te reageren op de auteur
Log in om door te sturen
Je hebt geen rechten om berichten in deze groep te verwijderen
Log in om het bericht te melden
Oorspronkelijk bericht tonen
E-mailadressen zijn anoniem voor deze groep of je moet het recht 'E-mailadressen van leden bekijken' hebben om het oorspronkelijke bericht te kunnen bekijken.
aan flextrine
i created zend_auth_adapter for flextrine (doctrine)
/**
* Doctrine auth adapter
*/
class DoctAuthAdapter extends \Flextrine\AbstractFlextrineService
implements Zend_Auth_Adapter_Interface
{
/**
* table name
*
* @var string
*/
private $_table;
/**
* The field name which will be the identifier (username...)
*
* @var string
*/
private $_identityCol;
/**
* The field name which will be used for credentials (password...)
*
* @var string
*/
private $_credentialCol;
/**
* Actual identity value (my_all_known_username)
*
* @var string
*/
private $_identity;
/**
* Actual credential value (my_secret_password)
*
* @var string
*/
private $_credential;
/**
* construct
* @param string $tableName auth table name
* @param string $identityCol identity column name
* @param string $credentialCol password column name
*/
public function __construct($table, $identityCol, $credentialCol)
{
//Assign the column names...
$this->_table = $table;
$this->_credentialCol = $credentialCol;
$this->_identityCol = $identityCol;
}
/**
* @param string $identity
*/
public function setIdentity($identity)
{
$this->_identity = $identity;
}
/**
* @param string $credential
*/
public function setCredential($credential)
{
$this->_credential = $credential;
}
/**
* @return Zend_Auth_Result
*/
public function authenticate()
{
$criteria = array(
$this->_identityCol => $this->_identity,
$this->_credentialCol => $this->_credential
);
$result = $this->loadBy($this->_table, $criteria, "eager");
return new Zend_Auth_Result($result[0]->id ?
Zend_Auth_Result::SUCCESS : Zend_Auth_Result::FAILURE, $result[0]-
>id ? $result[0] : null);
}
}
and then call from FlextrineService:
/**
* login user
* @param username
* @param password
* @return boolean
*/
public function loginUser($email, $password)
{
$authAdapter = new DoctAuthAdapter("Users", "email", "password");
$authAdapter->setIdentity($email);
$authAdapter->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
return ($result->isValid()) ? true : false;
}