[Catalyst] Roles: DBIC

Kiefer, Sascha sk at intertivity.com
Thu Jan 26 19:55:55 CET 2006


Hi,

I did setup a test app based on the Authentication-Store-DBIC doc
(http://search.cpan.org/~agrundma/Catalyst-Plugin-Authentication-Store-DBIC-
0.04/lib/Catalyst/Plugin/Authentication/Store/DBIC.pm) using DBIx. Login
works just fine, but 
the roles don't work. $c->check_user_roles( 'admin' ) returns 0.

my @roles = $c->user_object->roles; # roles = map_user_role returns me the
role with id 4 which means that it is a admin.

Besides of that i also added the following

__PACKAGE__->belongs_to(role => 'MyApp::Model::DBIC::OwmRole', 'roleId' ); 
__PACKAGE__->belongs_to(user => 'MyApp::Model::DBIC::OwmUser', 'userId' );

So no i can check myself

my $isAdmin = grep { $_->role->rolename eq 'admin' } @roles;

But this is not i want of cource.

--esskar

PS: Here my config.

authentication:
   dbic:
      user_class:           'MyApp::Model::DBIC::OwmUser'
      user_field:           'username'
      password_field:       'password'
      password_type:        'salted_hash'

      role_class:           'MyApp::Model::DBIC::OwmRole'
      role_field:           'rolename'
      role_rel:             'roles'
      user_role_user_field: 'userId'





More information about the Catalyst mailing list