I have used email verification for user login and authentication. I have written a code so that the status becomes status=1
when he clicks on the link sent to his email. And then he is redirected to login page. He needs to login with the same details given in registration. I have written a validation such that when the email address and password match then the user is authenticated and he is logged in. But I need to add one more condition that the validation must also check whether the status is 1, and user must be allowed to login only when status=1
. For this I need to add a variable in the login action and check for where status=1
. How do I do this?
In the below code I am getting validation for only email
and password
. How to get status=1
condition satisfied?
This is my loginAction
public function loginAction()
{
if(Zend_Auth::getInstance()->hasIdentity())
{
$this->_helper->redirector('register','user','default');
}
$authAdapter = $this->getAuthAdapter();
if(isset($_POST['submit']))
{
$post=$this->_request->getPost();
$email = $post['user_email'];
$password = $post['password'];
$authAdapter->setIdentity($email)
->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if($result->isvalid()){
$identity = $authAdapter->getResultRowObject();
$authStorage = $auth->getStorage();
$authStorage->write($identity);
$this->_helper->redirector('register','user','default');
echo 'valid';
} else {
$this->view->errorMessage = "User name or password is incorrect";
}
}
This is my statusAction
public function statusAction()
{
$url = explode('&',urldecode($this->_getParam('k')));
$data['email'] = $url[0];
$data['status'] = 1;
$data['access_key'] = $url[1];
$mapper = new Application_Model_UserMapper();
$status = $mapper->update($data);
$this->_helper->redirector('index','projects','default');
}