我有一些代码可以防止已删除和禁止的用户登录。为了清除头脑,状态为 -2 意味着用户被删除,-1 意味着用户被禁止。下面是在本地运行良好的代码,但在现场它很烂。状态为 -1 或 -2 的用户仍然可以登录。我找不到问题出在哪里。
if ($this->Auth->login()) {
//first check if the user's status is -1 or -2.
$status = $this->Auth->user('status');
if ($status == '-1') {
$this->Auth->logout();
$this->Session->setFlash(__('This account has been banned. Please contact with us.'));
$this->redirect('/');
} elseif ($status == '-2') {
$this->Auth->logout();
$this->Session->setFlash(__('This account has been deleted, and is not usable anymore.'));
$this->redirect('/');
}
//something else
}