2009年9月24日星期四

[fw-auth] a couple questions about customizing Zend_Auth


I have tried getting Zend_Auth_Adapter_DbTable's authenticate() to fetch data from multiple joined tables so that getResultRowObject() would give me everything about the user that I wanted to load into the session.  I used getDbSelect() to get the select and join() a table, and could not get it to work. (I actually thought I had it the other day, but it was a false positive.) Is this supposed to be possible? For example, I tried various variations on

$select = $authAdapter->getDbSelect();
$select
    ->where('users.active');
    ->join(array('groups'), 'groups.id = users.group_id',array('groups.name'=>'group'),array())
    ->join(array('people'),'users.person_id = people.id',array('lastname','firstname',))

and kept getting Zend_Auth_Adapter_Exception, invalid SQL statement.

In any event, I gave up on this approach and am now extending Zend_Auth_Adapter_DbTable and overriding authenticate(). Is this a reasonable solution?

Which brings me to the next question:  suppose you want to add an authentication failure code that means 'account disabled.'  Extend Zend_Auth_Result and have your authenticate return an instance of it?

Another possible solution:  create a view (at the database level) that pulls together all the columns I want from the different tables. Any thoughts?

Thanks.

--
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness

没有评论: