登录表格:
$authAdapter = Zend_Registry::get('authAdapter');
$authAdapter
->setIdentity($formData['email'])
->setCredential($password)
->setCredential(1);
自举:
protected function _initAuth(){
$this->bootstrap('db');
$this->bootstrap('session');
$db = $this->getPluginResource('db')->getDbAdapter();
$auth = Zend_Auth::getInstance();
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'User', 'email', 'password', 'enabled');
Zend_Registry::set('authAdapter', $authAdapter);
return $authAdapter;
}
显然,如果我删除了“启用”,它就会停止工作:
->setCredential(1);
从那里和'启用':
($db, 'User', 'email', 'password', 'enabled');
它运作得很好......
我只想启用已启用帐户的用户登录。
编辑:
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'User', 'email', 'password', '(?) AND `enabled` = 1');
有效:)
答案 0 :(得分:1)
您需要像这样修改适配器:
$authAdapter = new Zend_Auth_Adapter_DbTable(
$db,
'user',
'email',
'password',
'MD5(?) AND `enabled` = "true"');
答案 1 :(得分:1)
请尝试:
$authAdapter = new Zend_Auth_Adapter_DbTable($db, 'User', 'email', 'password', 'AND enabled > 1');
并删除:
->setCredential(1);
答案 2 :(得分:0)
您可以在身份验证适配器中设置其他条件,即
$select = $authAdapter->getDbSelect();
$select->where("isActive = ?","Active");