[Dancer-users] Dancer::Plugin::Auth::RBAC Application

Flavio Poletti polettix at gmail.com
Fri Apr 15 16:01:07 CEST 2011


Please report your errors as well.

At first glance, it seems that you're trying to use $auth as a global
variable, but you use "my" inside '/login' which means that inside that
route you're dealing with a different variable.

Cheers,

    Flavio.


On Thu, Apr 14, 2011 at 6:53 PM, Forgoselo Fontardion
<fontardion at gmail.com>wrote:

> Hi,
>
> I'm startirng to create a new web application, my first dancer's one.
>
> I'm testing the RBAC plugin. I've found a problem that I can't solve. When
> I try to use a function to check the status of the login, in example to
> check if a user has admin role or to revoke its permissions. In the cases
> previously described I found an error, because the $auth scalar variable is
> only accessible to the route '/'.
>
> get '/' => sub {
>   if $auth->asa('guest') ) {
>     redirect '/login';
>   }
>   else {
>     template 'index';
>   }
> };
>
> post '/login' => sub {
>     my $auth = auth(params->{username}, params->{password});
>     if (! $auth->errors) {
>       flash ok => 'Login ok';
>       redirect '/';
>     }
>     else {
>       flash error => 'Login Error';
>       redirect '/login';
>     }
>
> };
>
> get '/logout' => sub {
>     $auth->revoke();
>     flash ok => 'Session Closed';
>     redirect '/';
> };
>
> Best regards,
>                         Fontardion
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110415/93cbab94/attachment.htm>


More information about the Dancer-users mailing list