[Catalyst] optional login for some actions
Sai Tong
stong at fidelio.rutgers.edu
Thu Sep 29 16:30:39 CEST 2005
How, if it is possible, to allow login optionally for accessing some parts of the web application?
I created an action for simply displaying either one of two sets of links of URL storing in a database, and I want
to allow users to access different results of the actions,to either first sets of links or second sets of links,
based on whether or not the user logins (by using TT2 to post the link if the user has a particular role ).
I tried, in the App.pm, to not to force login for such action:
sub begin : Global {
my ($self, $c) = @_;
# don't force login
return 1 if ($c->req->{path} =~ /^static|optionalLoginAction/);
# force login for all pages
unless ($c->req->{user}) {
$c->req->action(undef);
$c->forward('/login/login');
}
}
Which would work the way I want. However, if after I login and logout with username that has the role for
accessing one (out of two) set of url link, and pass the back button on the browser, the previous page
would show up from the browser's cache, which is not what I want to happen. What I need is to force
this action to be reload every time when request of this action is called from the browser, because if
I manually reload the action with the browser's reload button, the result of this action with the correct link
will show up.
Does anyone have any suggestion of how to accomplish this type of option login mechanism?
More information about the Catalyst
mailing list