in reply to Catalyst Redirect Hints?
This can be semi-trivial in Cat. There are two ways to do it. The first, easiest, is debatably bad REST style (the content under any restricted URI becomes fluid; it's a login form or the real content) but the second can be tricky and has no "standard" implementation.
I recommend #1. Pseudo-code:
sub what_i_want : Local { $c->detach("login") unless $c->user_exists... roles... etc... do_interesting_restricted_stuff() } sub login : Local { if ( authenticated... ) { my $destination = $c->request->path eq 'login' ? $c->uri_for("/") : $c->uri_for( "/" . $c->request->path +); $c->response->redirect($destination); $c->detach(); } }
So, the user requests http://myapp/what_i_want but is presented with the login page since they aren't authenticated. The login posts to that same path, "what_i_want," until they are authenticated. Then just redirect to the requested path as long as it wasn't "login" to start with, that would be silly. Send them home -- "/" -- if they requested login to start the login process.
I know that can be a bit boggling at first but it's actually pretty straightforward once you get the right perspective on it. There is more of this in a few of the docs, sorry, no links right now. Let me (us) know if you get stuck on it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Catalyst Redirect Hints?
by holli (Abbot) on Mar 26, 2009 at 04:10 UTC | |
by Your Mother (Archbishop) on Mar 26, 2009 at 05:32 UTC |