[Dancer-users] params for post route not working

GJ gj at freeshell.org
Mon Feb 20 07:26:45 CET 2012


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?

GJ


More information about the Dancer-users mailing list