[Catalyst] Questions with Authentication/Authorization

Tomas Doran bobtfish at bobtfish.net
Thu Dec 8 09:46:49 GMT 2011


On 24 Nov 2011, at 12:40, Johannes Kilian wrote:
> Questions:
> * Isn't $c->user a persistent value within $c? When I try to access  
> to c.user later (after "successfull" login) $c->user is undefined.
> What is neccessary to make it persistent?

The Session plugin.

> * When I try to check the user role for example via $c- 
> >assert_user_roles( qw/Wizard/ );  
> (c.user.fk_bdbrolle_pk.bdbrolle_name has been Wizard in my example)  
> this fails completely: Caught exception in  
> BDBInfo2::Controller::Root->login "Can't locate object method  
> "search" via package "BDBInfo2::Model::BDB::Bdbrolle" at .../ 
> Catalyst/Authentication/Store/DBIx/Class/User.pm line 144." What's  
> wrong here?

Yeah, the user class expects you to have a many-to-many here.

The best solution is to subclass  
Catalyst::Authentication::Store::DBIx::Class::User in your application  
(as MyApp::User or whatever), then re-implement the 'roles' method to  
do the right thing for your Database..

You can then set the store_user_class config option to 'MyApp::User',  
and everything should work as expected..

Cheers
t0m




More information about the Catalyst mailing list