我已使用电子邮件验证进行用户登录和身份验证。我编写了一个代码,以便status=1
当他单击发送到他的电子邮件的链接时状态变为。然后他被重定向到登录页面。他需要使用注册时提供的相同详细信息登录。我已经编写了一个验证,这样当电子邮件地址和密码匹配时,用户就会通过身份验证并登录。但我需要再添加一个条件,验证还必须检查状态是否为 1,并且必须允许用户仅当登录status=1
。为此,我需要在登录操作中添加一个变量并检查where status=1
. 我该怎么做呢?在下面的代码中,我只获得了email
and的验证password
。如何status=1
满足条件?
这是我的登录操作
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";
}
}
这是我的状态动作
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');
}