2008年10月25日星期六

Re: [fw-auth] Zend_Auth_Adapter_DbTable and crypt($pass, $salt)

I haven't tested it, but you can probably use the credentialTreatment option, but it'd be a bit of a hack:

<?php
$authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);

$authAdapter
    ->setTableName('users')
    ->setIdentityColumn('username')
    ->setCredentialColumn('password') ->setCredentialTreatment('password') ;
?>
That (i think) would result in a SQL query that looks something like this:

SELECT * FROM users WHERE username = 'bob' AND password = password


On Sat, Oct 25, 2008 at 9:04 AM, Piotr Kabaciński <kabot@seo.pl> wrote:
Hello,

Is it possible to force DbTable adapter to not verify password, just to check if there is given login name or tu set my own verify-password method?
I have in user table column password but this password is crypted by php function crypt().
Problem is becouse of salt. I can't compare crypted password before I get salt in it.

Earlier i did something like this:
$ROW = "SELECT login, pass FROM user WHERE login=$login";
if ($ROW['pass'] == crypt($pass, $ROW['pass']))
 //it's ok

Have you ever had such a problem? Of course i can write my own adapter or extends it on Zend_Auth_Adapter_DbTable but would me nice if this one works fine.

greetings
--
Piotr Kabacinski
kabot@seo.pl




--
-Hector

没有评论: