Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make require_login and require_role available in the load_app #15

Open
pwfraley opened this issue Dec 23, 2012 · 2 comments
Open

make require_login and require_role available in the load_app #15

pwfraley opened this issue Dec 23, 2012 · 2 comments

Comments

@pwfraley
Copy link

It would be cool to be able to:

load_app 'App::User',   prefix => '/user', require_login
load_app 'App::Admin',   prefix => '/admin', require_role Admin

And then also be able to use it in the loaded apps:

package App::User
use Dancer ':syntax';

### you only get here if you are logged in, but the next action is only available if you are an Editor
get '/' => require_role Editor => sub {
    return 'You are Editor :)';
};

true;

Just an Idea, have not seen any possibility to do that yet ... maybe I overlooked something?

@bigpresh
Copy link
Owner

That would require hackery in Dancer's core itself, which I'm not sure is desireable.

Personally, if you have multiple apps loaded and want to protect all requests based on the app in use, I think I'd be inclined to use a before hook to implement the logic yourself (using the keywords provided by DPAE to check if the user is logged in / has a desired role).

I'll have a further think about this, but I'd like to avoid anything that would require changing Dancer's core at all.

@pwfraley
Copy link
Author

Oh I agree hackery in the Dancer core is not a good idea ... Would it be possible to do something like that in Dancer2?

Thanks for the tip about the before hook. I will try that.

Happy hollidays :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants