Try if like i shoewed before with a named route to some place. A general catchall or redirect to '/' is never a good idea
so in your controller you would have something like this
$r->route('/login') ->via('get') ->to('authn#form')->name('authn_form');
$r->route('/login') ->via('post')->to('authn#login');
my $rb = $r->bridge->to('authn#check');
$mb->route('/main')->to('main#index');
and in Authn.pm
sub check {
my $self = shift;
$self->redirect_to('authn_form') and return 0
unless($self->is_user_authenticated);
return 1;
}
________________________________
> Date: Tue, 31 Jul 2012 23:15:17 -0700
> From:
am...@rae-consulting.com
> > To:
mojol...@googlegroups.com<mailto:
mojol...@googlegroups.com>
> > Subject: Re: [Mojolicious] Authenticating Routes
> >
> > Thanks David for the info. Following is the code inside check:
> >
> > sub check {
> > my $self = shift;
> > return 0 unless($self->is_user_authenticated);
> > return 1;
> > }
> >
> > On Monday, July 30, 2012 1:26:51 PM UTC+5:30, David Oswald wrote:
> > > 'main', Main::check, main::check, Main::check,
> > > main::check code (pay attention to capitalization).
> >
> > You see, even after talking about it, I still am getting it mixed up.
> > 'main' vs 'Main'. ...that controller name is begging to be changed to
> > something that doesn't resemble Perl's default package. ;)
> >
> >
> > --
> >
> > David Oswald
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Mojolicious" group.
> > To view this discussion on the web visit
> >
https://groups.google.com/d/msg/mojolicious/-/_uy0fIj3haIJ.
> > To post to this group, send email to
>
mojol...@googlegroups.com<mailto:
mojol...@googlegroups.com>.
> > To unsubscribe from this group, send email to
> >
>
mojolicious...@googlegroups.com<mailto:
mojolicious%2Bunsu...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "Mojolicious" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/mojolicious/-/AnH1vfcVzzoJ.
>
mojolicious...@googlegroups.com.