[Catalyst] check_user_roles [ $user ], @roles ?
Felix Antonius Wilhelm Ostmann
ostmann at websuche.de
Wed Feb 4 13:50:13 GMT 2009
From the code:
if ( Scalar::Util::blessed( $roles[0] )
&& $roles[0]->isa("Catalyst::Authentication::User") )
{
$user = shift @roles;
}
$user ||= $c->user;
unless ( $user ) {
Catalyst::Exception->throw(
"No logged in user, and none supplied as argument");
}
Catalyst::Exception->throw("User does not support roles")
unless $user->supports(qw/roles/);
i think you can give a string ... you must load the user into a
user-object fit for the Authorization::Roles
Jens Schwarz schrieb:
> Hi *,
>
> in my Catalyst app I use $c->check_user_roles(qw/Admin/) to determine, if the currently logged in user is part of the Admin role. Works fine.
>
> Now I want to check if _another_ (currently _not_ logged in user) is part of the Admin role. I read the documentation of Catalyst::Plugin::Authorization::Roles and found that check_user_roles can optionally take $user as additional parameter. But it does not work as I suspected: With ...
>
> $c->log->info(">> " . $c->check_user_roles( "some_other_user" , qw/Admin/ ));
>
> ... Catalyst debug just gives me ...
>
> [debug] Role denied: some_other_user, Admin
> [info] >>
>
> ... where I expected something like ...
>
> [info] >> 1
>
> "some_other_user" is a username string, in the column "username" of my user table. myapp/myapp.conf ist setup accordingly (i.e.: user_class myapp::user and id_field username).
>
> What am I doing wrong?
>
> Jens
>
--
Mit freundlichen Grüßen
Felix Antonius Wilhelm Ostmann
--------------------------------------------------
Websuche Search Technology GmbH & Co. KG
Martinistraße 3 - D-49080 Osnabrück - Germany
Tel.: +49 541 40666-0 - Fax: +49 541 40666-22
Email: info at websuche.de - Website: www.websuche.de
--------------------------------------------------
AG Osnabrück - HRA 200252 - Ust-Ident: DE814737310
Komplementärin: Websuche Search Technology
Verwaltungs GmbH - AG Osnabrück - HRB 200359
Geschäftsführer: Diplom Kaufmann Martin Steinkamp
--------------------------------------------------
More information about the Catalyst
mailing list