| Jifty documentation | Contained in the Jifty distribution. |
Jifty::Plugin::Authentication::Password::Dispatcher - password plugin dispatcher
All the dispatcher rules jifty needs to support Jifty::Authentication::Password/
before logoutLogout and return home.
See Jifty::Plugin::Authentication::Password::Action::Logout.
before *Setup the navigation menu for login or logout.
on qr/^(?:signup|lost_password)$/Redirect to home if logged.
Request a password reminder or signup for an account otherwise.
on loginRedirect to home if logged.
Show the login form otherwise.
before reset_lost_passwordRequest a password reset.
before passwordreminderRequest a new password reminder to be sent by email.
See Jifty::Plugin::Authentication::Password::Action::SendPasswordReminder.
before signupSign up for an account.
See Jifty::Plugin::Authentication::Password::Action::Signup.
before loginLogin to your account.
Jifty is Copyright 2005-2010 Best Practical Solutions, LLC. Jifty is distributed under the same terms as Perl itself.
| Jifty documentation | Contained in the Jifty distribution. |
use strict; use warnings; package Jifty::Plugin::Authentication::Password::Dispatcher; use Jifty::Dispatcher -base;
before 'logout' => run { Jifty->web->new_action( class => 'Logout', moniker => 'logout')->run; redirect '/'; }; # Make sure tangents work # Before password reminders, login or signup, let's push the user off to the homepage if they're logged in
before '*' => run { my ($ap) = Jifty->find_plugin('Jifty::Plugin::Authentication::Password') or return; return unless $ap->nav_menu; if ( Jifty->web->current_user->id ) { logged_in_nav(); } else { not_logged_in_nav(); } };
before qr'^/(?:signup|lost_password)$' => run { redirect('/') if ( Jifty->web->current_user->id ); set 'next' => Jifty->web->request->continuation || Jifty::Continuation->new( request => Jifty::Request->new( path => "/login" ) ); };
before qr|^/(?:login)$| => run { redirect('/') if ( Jifty->web->current_user->id ); set 'next' => Jifty->web->request->continuation || Jifty::Continuation->new( request => Jifty::Request->new( path => "/" ) ); };
before qr|(?:reset_lost_password)| => run { set 'next' => Jifty->web->request->continuation || Jifty::Continuation->new( request => Jifty::Request->new( path => "/" ) ); }; # Send a password reminder for a lost password
before 'passwordreminder' => run { set 'action' => Jifty->web->new_action( class => 'SendPasswordReminder', moniker => 'password_reminder'); };
before 'signup' => run { set 'action' => Jifty->web->new_action( class => 'Signup'); };
before 'login' => run { set 'action' => Jifty->web->new_action( class => 'Login'); };
sub not_logged_in_nav { Jifty->web->navigation->child( 'Login', link => Jifty->web->tangent( label => _('Login'), url => '/login' ), sort_order => '999' ); Jifty->web->navigation->child( 'Signup', link => Jifty->web->tangent( label => _('Sign up'), url => '/signup' ), sort_order => '950' ); }
sub logged_in_nav { Jifty->web->navigation->child( Logout => label => _('Logout') => url => '/logout', sort_order => '999' ); }
1;