Anandhan
Anandhan

Reputation: 432

ZEND Authentication FAILS

I have been creating user login form using the various groupcodes, the user login has to work based on the unique groupcodes.Let me explain these in detail there are two users called (X and Y) exists in the site with the following details

X  [email protected] pwd- 123456 ,groupcode-TESTCODE
Y  [email protected] pwd-test124, groupcode-TESTCODE2    

My Authcontroller

$adapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter(),
                                        'users',
                                        'login',
                                        'password',
                                        'MD5(?)','groupcode','TESTCODE');

$adapter->setIdentity($form->getValue('username'))
                     ->setCredential($form->getValue('password'));  

$result = Zend_Auth::getInstance()->authenticate($adapter); 

The result alwyas through the Authentication went Wrong error messsage. The default authcontroller takes the idenfity from the both the user rows, it doesn't takes from the user unique row value.

Upvotes: 0

Views: 316

Answers (1)

drew010
drew010

Reputation: 69937

I'm not sure I completely understand the problem, but hopefully one of these solutions can help you.

First, you are passing 7 arguments to the Zend_Auth_Adapter_DbTable constructor, but its constructor only accepts 5 arguments, so groupcode and testcode have no effect in your code.

Since you are probably going to get more than 1 result, setting ambiguity identity flag may work for you. Set it by calling $adapter->setAmbiguityIdentity(true); so that if more than 1 result is returned, it will look at each one for a password match.

If you need to pass groupcode and testcode, then you probably need to create your own auth adapter. You could extend from Zend_Auth_Adapter_DbTable to take advantage of what it has already done, but override authenticate() so that it takes your groups into consideration.

Or, you could use Zend_Auth to check for an identity, but not use its authenticate method at all, and just write your own class to validate the user login, and then use Zend_Auth to set the identity.

Upvotes: 2

Related Questions