Skip to content

Instantly share code, notes, and snippets.

@s7anley
Created November 17, 2015 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s7anley/b497c7cd05dec10ee75f to your computer and use it in GitHub Desktop.
Save s7anley/b497c7cd05dec10ee75f to your computer and use it in GitHub Desktop.
Zend_Auth_Adapter_BcryptDbTable
<?php
class Base_Auth_Adapter_BcryptDbTable extends Zend_Auth_Adapter_DbTable
{
/**
* @inheritdoc
*/
protected function _authenticateCreateSelect()
{
$dbSelect = clone $this->getDbSelect();
$dbSelect->from($this->_tableName)
->where($this->_zendDb->quoteIdentifier($this->_identityColumn, true) . ' = ?', $this->_identity);
return $dbSelect;
}
/**
* @inheritdoc
*/
protected function _authenticateValidateResult($resultIdentity)
{
$passwordCheck = password_verify($this->_credential, $resultIdentity[$this->_credentialColumn]);
if (!$passwordCheck) {
$this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
$this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
return $this->_authenticateCreateAuthResult();
}
$this->_resultRow = $resultIdentity;
$this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;
$this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
return $this->_authenticateCreateAuthResult();
}
}
@C-Duv
Copy link

C-Duv commented Sep 7, 2020

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment