[dancer-users] load_app, prefix, require_login (or role)
Henk van Oers
hvo.pm at xs4all.nl
Fri Jun 14 19:22:09 BST 2013
I am using Dancer::Plugin::Auth::Extensible
but what I want is more general.
I use in my app:
prefix '/user' => sub {
get '/' => require_login sub {
my $user = logged_in_user;
template 'user', { user => $user };
};
};
No problem with that.
I also use in my app:
load_app 'Bla', prefix => '/bla';
I would like to restrict the routes to that app to only
users with a matching role.
That would make "load_aps"s reuseable for other apps
with a differend role mechanisem.
e.g. In Bla.pm you can have:
get '/request' => sub {
my $req = request;
reveal('request', \$req);
};
In contrast to:
get '/foo' => require_role($i_do_not_know_the_role) => sub { ... };
--
Henk
PS:
any '/logout' => sub {
session->destroy;
redirect '/';
};
Can be a global route for any Danser app,
if there is nothing to match anymore.
More information about the dancer-users
mailing list