// Get our authentication adapter and check credentials
$adapter = $this->_getAuthAdapter();
//Need to add more credential for user
$select = $adapter->getDbSelect();
$select->where('status = 1 AND password is not null AND password!=""');
$adapter->setIdentity($values['username']);
$adapter->setCredential(md5($values['password']));
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$user = $adapter->getResultRowObject();
$auth->getStorage()->write($user);
return $this->_redirect('/sitemgr/pages');
}
//or else we can use following simple code
$adapter = $this->_getAuthAdapter();
//Need to add more credential for user
$select = $adapter->getDbSelect();
$select->where('status = 1 AND password is not null AND password!=""');
$adapter->setIdentity($values['username']);
$adapter->setCredential(md5($values['password']));
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$user = $adapter->getResultRowObject();
$auth->getStorage()->write($user);
return $this->_redirect('/sitemgr/pages');
}
//or else we can use following simple code
$authAdapter->setTableName('register')
->setIdentityColumn('username')
->setCredentialColumn('pwd')
->setCredentialTreatment('? AND status = "active"');
No comments:
Post a Comment