views:

157

answers:

2

A short question for the PROs. Is it possible to use Zend_Auth_Adapter_DbTable with ZendX_Db_Adapter? I've tried this:

$adapter = new Zend_Auth_Adapter_DbTable(
    Zend_Registry::get('db')
);
$adapter->setTableName('USERS')
    ->setIdentityColumn('username')
    ->setCredentialColumn('password')
    ->setIdentity('FOO')
    ->setCredential('BAR');
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate();

But it doesn't work. ErrorMsg: Catchable fatal error: Argument 1 passed to Zend_Auth::authenticate() must implement interface Zend_Auth_Adapter_Interface, none given, called in D:\xampp\htdocs\liquisales-online\application\controllers\IndexController.php on line 35 and defined in D:\xampp\htdocs\liquisales-online\library\Zend\Auth.php on line 115

Any hints? Btw. ZendX_Db_Adapter ist registerd in application.ini

resources.db.adapter = Firebird
resources.db.params.dbname = "/var/db/liquisales.FDB"
resources.db.params.host = "127.0.0.1"
resources.db.params.username = sysdba
resources.db.params.password = masterkey
resources.db.params.adapterNamespace = "ZendX_Db_Adapter"
+1  A: 

it seems your adapter doesn't implement all the methods needed .... so you would have to code the authentication yourself.

RageZ
+2  A: 

Okay, here is the right way to use Firebird DB with Zend_Auth. At first we had to use capitol letters for column names. Furthermore I've forgotten to pass the adapter.

Here's the right code.

$adapter = new Zend_Auth_Adapter_DbTable(
    Zend_Registry::get('db')
);
$adapter->setTableName('USERS')
    ->setIdentityColumn('USERNAME')
    ->setCredentialColumn('PASSWORD')
    ->setIdentity($loginForm->getValue('kunummer'))
    ->setCredential($loginForm->getValue('passwd'));
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
former