<div>The flash is moved to the stash after the redirect, and then it's gone after that, right?</div><div><br></div>What we do is stuff the intended destination into the session and then pull it from there:<div><br></div>
<div><div>sub login : Chained('/') PathPart('login') Args(0) {</div><div> my ( $self, $c ) = @_;</div><div><br></div><div> my $form = Spill::Form::Login->new( action => $c->uri_for('/login') );</div>
<div><br></div><div> $c->stash(</div><div> template => 'login.tt2',</div><div> form => $form,</div><div> );</div><div><br></div><div> if ( $c->action ne 'login' ) {</div>
<div> # Stuff destination into session for later redirect if user authenticates</div><div><b> $c->session->{redirect} = $c->req->uri->as_string;</b></div><div> }</div><div><br></div><div>...then, later, after authenticating...</div>
<div><br></div><div><div> my $go = <b>delete( $c->session->{redirect} )</b> || $c->req->headers->referer;</div><div> $go = '/' if $go =~ /\blog(in|out)\b/;</div><div> $c->res->redirect( $go );</div>
<div> $c->detach;</div></div><div><br></div><br><div class="gmail_quote">On Sun, Jan 23, 2011 at 8:27 PM, Eric Berg <span dir="ltr"><<a href="mailto:eberg@bergbrains.com">eberg@bergbrains.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">If a user submits a certain form without being logged in, I flash the current URL, save the params in the session, and redirect them to the login.<br>
<br>
In my Login controller, I look for $c->flash->{redirect_url} and redirect them back to that URL.<br>
<br>
The problem is that that flash entry is gone after the user submits the login form. I logged out the redirect URL at the beginning of my login routine and it comes through the first time, but even if I don't access it via the log statement, that redirect_url key is not there in the flash when the user submits the login form with their credentials.<br>
<br>
I've tried resetting $c->flash->{redirect_url} in the login routine and also tried $c->keep_flash( qw( redirect_url )) in the login routine, but no go.<br>
<br>
Any thoughts on what I might be doing wrong?<br>
<br>
Eric<br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>The first step towards getting somewhere is to decide that you are not going to stay where you are. -- J.P.Morgan<br>
</div>