2015-10-21 19:02 GMT-05:00 Richard Reina <gatorreina@gmail.com>:
Oops let me try again. So far in my app I have been restricting access to registered users that have created an account by doing:
get '/dashboard' => sub {
if (! defined(session 'username')) {
redirect '/'; }
}
Is this okay? I really don't have any special roles to authenicate just need to make sure that registered users only get to certain pages -- pages that would only make sence if you were a registered user in the first place. Can I forgoe more formal and extensive authentication in my case?
2015-10-21 19:00 GMT-05:00 Richard Reina <gatorreina@gmail.com>:
So far in my app I have been restricting access to registered users that have created an account by doing:
get '/dashboard' => sub { if (! defined(session 'username')) { redirect '/'; } } Is this okay? I really don't have any special roles to authenicate just need to make sure that registered users only get to certain pages -- pages that would only make sence if you were a registered user in the first place. Can I forgoe more formal and extensive authentication in my case?
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Wed, 2015-10-21 at 19:04 -0500, Richard Reina wrote:
Can I forgoe more formal and extensive authentication in my case?
Yes, but it would still be easier for you to use a plugin, such as Dancer2::Plugin::Auth::Extensible or Dancer2::Plugin::Auth::Tiny In the case of the former, all you need is as follows. It will even generate the login and logout routes: use Dancer2::Plugin::Auth::Extensible; get '/restricted' => require_login sub { ... } plugins: Auth::Extensible: realms: config: provider: Config users: - user: andy pass: secret # or encrypted
2015-10-22 0:49 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Wed, 2015-10-21 at 19:04 -0500, Richard Reina wrote:
Can I forgoe more formal and extensive authentication in my case?
Yes, but it would still be easier for you to use a plugin, such as Dancer2::Plugin::Auth::Extensible or Dancer2::Plugin::Auth::Tiny
In the case of the former, all you need is as follows. It will even generate the login and logout routes:
use Dancer2::Plugin::Auth::Extensible;
get '/restricted' => require_login sub { ... }
plugins: Auth::Extensible: realms: config: provider: Config users: - user: andy pass: secret # or encrypted
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Thanks Andy. I intend on adopting D2 Auth:Extensible in the future especially, when I begin to have the need for roles. Appreciate the advice.
Hi, On Thu, Oct 22, 2015 at 3:29 PM, Richard Reina <gatorreina@gmail.com> wrote:
2015-10-22 0:49 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Wed, 2015-10-21 at 19:04 -0500, Richard Reina wrote:
Can I forgoe more formal and extensive authentication in my case?
Yes, but it would still be easier for you to use a plugin, such as Dancer2::Plugin::Auth::Extensible or Dancer2::Plugin::Auth::Tiny
In the case of the former, all you need is as follows. It will even generate the login and logout routes:
use Dancer2::Plugin::Auth::Extensible;
get '/restricted' => require_login sub { ... }
plugins: Auth::Extensible: realms: config: provider: Config users: - user: andy pass: secret # or encrypted
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Thanks Andy. I intend on adopting D2 Auth:Extensible in the future especially, when I begin to have the need for roles. Appreciate the advice.
Another option is using a hook which is also mentioned at link : https://metacpan.org/pod/Dancer2::Manual hook before => sub { if (!session('user') && request->dispatch_path !~ m{^/login}) { # Pass the original path requested along to the handler: forward '/login', { requested_path => request->dispatch_path }; } }; At each request, hook will be executed and check if user is registered or not. But at your application, if there are some pages which can be visited without registration, it is needed use plugin offered by Andrew.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- Kadir Beyazlı Computer Engineer GSM : +90 535 821 50 00
participants (3)
-
Andrew Beverley -
Kadir Beyazlı -
Richard Reina