CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect - redirect users who login back to the page they originally requested.
package MyApp::Controller::NeedsAuth; use Moose; use namespace::autoclean; # One needs to inherit from Catalyst::Controller::ActionRole in order # to get the Does('NeedsLogin') functionality. BEGIN { extends 'Catalyst::Controller::ActionRole'; } sub inbox : Path Does('NeedsLogin') { # Redirects to /login if not logged in my ($self, $c) = @_; $c->stash->{template} = "inbox.tt2"; return; } # Turn on in config MyApp->config('Contoller::Login' => { traits => 'WithRedirect' });
Provides the login action with a wrapper to redirect to a page which needs authentication, from which the user was previously redirected. Goes hand in hand with Catalyst::ActionRole::NeedsLogin
login
Make it use and extract $c->session->{redirect_to_after_login} if it exists.
$c->session->{redirect_to_after_login}
This sets the error message to $message and sets $c->session->{redirect_to_after_login} to the current URL.
See CatalystX::SimpleLogin for authors.
See CatalystX::SimpleLogin for license.
To install CatalystX::SimpleLogin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CatalystX::SimpleLogin
CPAN shell
perl -MCPAN -e shell install CatalystX::SimpleLogin
For more information on module installation, please visit the detailed CPAN module installation guide.