[Catalyst] question about authorization and roles

Dmitry L. dim0xff at gmail.com
Tue Feb 10 08:26:07 GMT 2015


What do you get in debug console output?
By code (Catalyst::Plugin::Authorization::Roles) you have to see
something like this:
Role denied: @roles

Anyway, you should look into Catalyst::Plugin::Authorization::Roles
and try debug it, code is simple.

On 10 February 2015 at 11:01, Luca Ferrari <fluca1978 at infinito.it> wrote:
> 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
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



-- 
//wbr, Dmitry L.



More information about the Catalyst mailing list