I am getting below error while running Login Authentication Code on. I am using zend framework & zend studio as IDE
A value for the identity was not provided prior to authentication with
Zend_Auth_Adapter_DbTable
.
Below is the code which i have written:
public function authAction(){
$request = $this->getRequest();
$registry = Zend_Registry::getInstance();
$auth = Zend_Auth::getInstance();
$DB = $registry['zenddb']; //zenddb is database name
$authAdapter = new Zend_Auth_Adapter_DbTable($DB);
$authAdapter->setTableName('user');
$authAdapter->setIdentityColumn('user_name');
$authAdapter->setCredentialColumn('password');
// Set the input credential values
$uname = $request->getParam('user_name');
$paswd = $request->getParam('password');
$authAdapter->setIdentity($uname);
$authAdapter->setCredential(md5($paswd));
// Perform the authentication query, saving the result
$result = $auth->authenticate($authAdapter);
if($result->isValid()){
$data = $authAdapter->getResultRowObject(null,'password');
$auth->getStorage()->write($data);
$this->_redirect('userpage');
}else{
$this->_redirect('login');
}
}