[Dancer-users] params for post route not working

Joel Roth joelz at pobox.com
Mon Feb 20 20:29:12 CET 2012


On Mon, Feb 20, 2012 at 06:26:45AM +0000, GJ wrote:
> On Sun, Feb 19, 2012 at 04:01:36PM -1000, Joel Roth wrote:
> > On Sun, Feb 19, 2012 at 11:20:48PM +0000, GJ wrote:
> > > Hi all,
> > > 
> > > I am using Dancer 1.3092 .  I can't access or use params for post routes, eg
> > > 
> > > ----
> > > post '/login' => sub {
> > >     # Validate the username and password they supplied
> > >     if (params->{user} eq 'bob' && params->{pass} eq 'a') {
> > >         session user => params->{user};
> > >         redirect params->{path} || '/';
> > >     } else {
> > >         redirect '/login?failed=1';
> > >     }
> > > };
> > 
> > This code works for me when used with (now-deprecated)
> > before.
> > 
> > I recall difficulties getting documentated examples
> > to work as advertised.
> > 
> > 
> > post '/login' => sub {
> > 	if ( validation_succeeds() )
> >     {
> >         session user => params->{user};
> >         my $path = session->{requested_path} || '/';
> >         session requested_path => undef;
> >         session failed_login => undef;
> >         redirect $path;
> > 
> >      } 
> >      else 
> >      {
> > 
> > 		session failed_login => 1;
> > 		redirect '/login'
> >      }          
> 
> Thanks Joel.  That doesn't work for me, but there is a 500 involved, so that
> may be a separate issue from getting Dancer to grok params, presuming
> validation_succeeds() is a Dancer method?

No, it's just a stand-in for whatever authentication you
use, i.e.

> > >     if (params->{user} eq 'bob' && params->{pass} eq 'a') {

-- 
Joel Roth


More information about the Dancer-users mailing list