[Catalyst] question about authorization and roles

Luca Ferrari fluca1978 at infinito.it
Tue Feb 10 08:01:44 GMT 2015


Ciao,
this is what I did in order to get more info:

# in the controller

if ( ! $c->check_any_user_role( qw/Admin Manutentore/ ) ) {
        $c->stash->{ message } = "User exists " . $c->user_exists() .
" - with username " . $c->user->username . " and roles "\
 . $c->user->roles_to_string . " and the check is " .
$c->check_any_user_role(  qw/Admin Manutentore/ );
        my @roles = $c->user->users_roles->all();
        @roles = map { $_->role->pk . " = " . $_->role->description }
@roles;
        $c->stash->{ message } .= "Roles [@roles]";
                                             }


and what is printed is:

User exists 1 - with username fluca1978 and roles [Manutentore] and
the check is 0Roles [12 = Manutentore]

so:
1) the user exists
2) the username is correct
3) the user has one role, the description of the role is matched
4) the check_any_user_role reports false (0)
5) the lookup of all the roles reports the right primary key and description.

Any idea about what I'm missing?

Thanks,
Luca

On Mon, Feb 9, 2015 at 9:43 PM, Luca Ferrari <fluca1978 at infinito.it> wrote:
> Ciao,
>
> On Mon, Feb 9, 2015 at 6:12 PM, Jeff Black <jeffrey.black at yahoo.com> wrote:
>>
>> Perhaps it's a stupid question, but have you checked that the user exists?
>>
>> if ( $c->user_exists() && ...
>>
>
>
> Apparently it exists because I print the username and its role list to
> check...and of course the role is there.
>
> Luca



More information about the Catalyst mailing list