<div class="gmail_quote">On Wed, Sep 30, 2009 at 8:09 AM, Bill Moseley <span dir="ltr"><<a href="mailto:moseley@hank.org">moseley@hank.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><div class="gmail_quote"><div class="im">On Wed, Sep 30, 2009 at 7:30 AM, Derek Wueppelmann <span dir="ltr"><<a href="mailto:dwueppel@gmail.com" target="_blank">dwueppel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm actually doing forwards to my login page right now. So that when a<br>
user logs in they can still see the page they were originally trying to<br>
view. I capture the URL they were attempting to view in the login<br>
process.<br></blockquote></div><div><br>And then redirect back to that original page after login? <br></div><div><br>I pass that data via the cache or session. <br></div><div><br>$c->cache->set( $key, { <br> orig_url => $url,<br>
message => 'Auhorization is required',<br> });<br><br>$c->res->redirect( $c->uri_for( '/login', { info => $key } ) );<br><br><br>Catalyst docs show an example using auto. BTW - shouldn't the redirect be an absolute-URI?<br>
<br> sub auto : Private {<br> my ( $self, $c ) = @_;<br> if ( !$c->user_exists ) { # Catalyst::Plugin::Authentication<br> $c->res->redirect( '/login' ); # require login<br>
return 0; # abort request and go immediately to end()<br> }<br> return 1; # success; carry on to next action<br> }<br></div></div></blockquote><div> <br><br>My typical recipe is via parameter, rather than session. This is more flexible, and allows me to pass URLs to people with more definitive results.<br>
<br>You do, however, have to whitelist the URLs prior to redirection. The very basic recipe is just something to compare the URI base:<br><br> my $redir = URI->new( $redir_url );<br> $redir->base eq $c->req->uri->base;<br>
<br>-J<br><br></div></div>