> $adapter->getDbSelect()->where('system_id = 20');
perfect! it works fine!
"getDbSelect() - Return the preauthentication Db Select object for
userland select query modification"
from method comment
i didn't see that the adapter keep a object in cache (one per adapter
instance), so...
thanks a lot!
2009/7/28 Ralph Schindler <ralph.schindler@zend.com>:
>
>>
>> $adapter = Zend_Auth_Adapter_DbTable();
>> $adapter->setTableName('user')
>> ->setIdentityColumn('username')
>> ->setCredentialColumn('password')
>> ->setCredentialTreatment('md5(?) and system_id = 20')
>> ->setIdentity('renanbr')
>> ->setCredential('123');
>> $result = Zend_Auth::getInstance()->authenticate($adapter)->isValid();
>>
>> $result is false, the error code is
>> Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS, but just one row has
>> "zend_auth_credential_match = 1"
>>
>
> This is an interesting use case. I would say that your 'identity', in this
> case, is actually the combination of both the username and the system_id.
> The way you are describing it above is that the combination of the password
> and system_id makes up the credential (which is conceptually not what you
> want.)
>
> One thing you could do is get the select object to further identify the
> proper identity. So, assuming your code above, it might look like this:
>
>
> $adapter = Zend_Auth_Adapter_DbTable();
> $adapter->setTableName('user')
> ->setIdentityColumn('username')
> ->setCredentialColumn('password')
> ->setCredentialTreatment('md5(?)')
> ->setIdentity('renanbr')
> ->setCredential('123')
>
> // add a where clause to the internal select object
> $adapter->getDbSelect()->where('system_id = 20');
>
> $result = Zend_Auth::getInstance()->authenticate($adapter)->isValid();
>
> I am pretty sure that will remove the ambiguity from the identity clause at
> authenticate() time.
>
> Hope this helps,
> Ralph Schindler
>
--
Renan de Lima Barbosa
gtalk/msn: renandelima@gmail.com
skype: renandelima
+55 61 8166-7755
renandelima.com
没有评论:
发表评论