[Catalyst] upon successful login, how do i get redirect users back to the page they wanted to access previously?

Matt S Trout dbix-class at trout.me.uk
Sun Apr 19 10:24:00 GMT 2009


On Sun, Apr 19, 2009 at 07:06:14AM +0900, J. Shirley wrote:
> On Sat, Apr 18, 2009 at 10:19 PM, <kakimoto at tpg.com.au> wrote:
> > I tried using FLASH and yet it doesn't work for me.
> > The value  I set in the flash gets lost after a redirect. Sorry to ask
> > but does flash really work and is it reliable? I know setting stuff in
> > the session variable is definitely reliable.

That was a really silly question.

"Does X really work" is basically saying "are the developers idiots?". If it
didn't work, we'd have a failing test case and be trying to write a patch or
it'd go into the docs.

Of course, flash by its nature isn't always safe under e.g. multiple tab
situations etc. but that's down to -what- it is, not the implementation.

> >
> >  1) I access www.lginsurance.com.au/subscriptions/add
> >  2) Since I am not logged in, Root->auto() kicks in and calls
> > Login->index()

Ok, so at this point you haven't changed the URL at all. Why bother changing
it?

What I usually do is $c->forward to my login action, which tests for
__login_user and __login_pass fields and if present, tries to login. If
that works, it just returns and the request goes on as normal. If not,
it sets up the login form and does $c->detach.

For bonus points you can save the POST params (if any) and the HTTP method
(if not POST) into the login form so you can provide the exact same
environment - you can't redirect to a POSt request but you -can- allow
one to continue ...

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list