Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add condition for Zend_Auth_Adapter_DbTable

This may seem like a silly question, but in this code, where would I insert the condition 'WHERE state=1'

    public function loginByUsernameAndPassword($username, $password)
    {   
        $this->_auth_adapter = new Zend_Auth_Adapter_DbTable( $this->getAdapter() );
        $this->_auth_adapter->setTableName('zend_administration_user')
                            ->setIdentityColumn('user_nm')
                            ->setCredentialColumn('password')
                            ->setCredentialTreatment('SHA1(CONCAT(?,salt))');
        $this->_auth_adapter->setIdentity($username)
                            ->setCredential($password);
        $result = Zend_Auth::getInstance()->authenticate($this->_auth_adapter);
        return $result->isValid();
    }
like image 251
Moak Avatar asked Jan 20 '23 18:01

Moak


1 Answers

Based on an example in the zf manual, I would say you could add AND state=1 into your setCredentialTreatment() method:

->setCredentialTreatment('SHA1(CONCAT(?,salt)) AND state = 1');
like image 175
Marcin Avatar answered Jan 30 '23 20:01

Marcin