[Catalyst]Roles

Tiziano Faion tiziano at e-tip.net
Thu Oct 26 11:28:37 BST 2006


Hi All!

I'm Implementing, in an catalyst application, roles based authorization.
I'm using C::P::A::Roles but I've a little problem.
I've defined all Models in the right way ( i suppose)

Now... I need to know the role id that user has... (if users is an admin
and admin role has id = 102 for example.. i need to have 102 returned)
and i've done a thing like this...

my $user = $c->model('Dbs')->resultset('Users')->search({
username => $user_name
})->first;

and than $user->users2roles->idrole,

where users2roles is defined in this way in Users model file

__PACKAGE__->has_many( users2roles => 'MeeksDbs::Usr2Rls' , 'iduser' );

but this says that :
[error] Caught exception in
Meeks::Controller::Login->get_json_user_level "Can't locate object
method "idrole" via package "DBIx::Class::ResultSet"
at /var/www/Meeks/svn/trunk/script/../lib/Meeks/Controller/Login.pm line
134."

I know that there is a method to check user roles automatically but i
need to keep the compatibility with an older part of code written
without use roles so i need to give the role id out...

Any suggestions? 
Greetings Tiziano 







More information about the Catalyst mailing list