[Jifty-commit] r2954 - in jifty/trunk: lib/Jifty/Plugin lib/Jifty/Plugin/Authentication/Password

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Mar 13 14:12:17 EDT 2007


Author: jesse
Date: Tue Mar 13 14:12:17 2007
New Revision: 2954

Added:
   jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Dispatcher.pm
   jifty/trunk/lib/Jifty/Plugin/Authentication/Password/View.pm
   jifty/trunk/lib/Jifty/Plugin/LetMe.pm
Modified:
   jifty/trunk/   (props changed)

Log:
 r53375 at pinglin:  jesse | 2007-03-13 14:11:44 -0400
  * oops. unpushed


Added: jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Dispatcher.pm	Tue Mar 13 14:12:17 2007
@@ -0,0 +1,72 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Authentication::Password::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+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
+
+on '*' =>  run {
+    if ( Jifty->web->current_user->id ) {
+        logged_in_nav();
+    } else {
+        not_logged_in_nav();
+
+    }
+
+};
+
+on qr/^(?:passwordreminder|signup|login)$/ => run {
+    redirect('/') if ( Jifty->web->current_user->id );
+    set 'next' => Jifty->web->request->continuation || Jifty::Continuation->new( request => Jifty::Request->new( path => "/" ) );
+};
+
+# Send a password reminder for a lost password
+
+on 'passwordreminder' => run {
+    set 'action' => Jifty->web->new_action( class => 'SendPasswordReminder', moniker => 'password_reminder');
+};
+
+# Sign up for an account
+on 'signup' => run {
+    set 'action' => Jifty->web->new_action( class => 'Signup');
+
+};
+
+# Login
+on 'login' => run {
+    set 'action' => Jifty->web->new_action( class => 'Login');
+};
+
+sub not_logged_in_nav {
+    Jifty->web->navigation->child(
+        Login   => label => _('Login') =>
+            url => '/login',
+        sort_order => '999'
+    );
+    Jifty->web->navigation->child(
+        Signup  => 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;

Added: jifty/trunk/lib/Jifty/Plugin/Authentication/Password/View.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Password/View.pm	Tue Mar 13 14:12:17 2007
@@ -0,0 +1,120 @@
+use utf8;
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::Authentication::Password::Login::View
+
+=head1 DESCRIPTION
+
+This code is only useful on the new Jifty "Declarative tempaltes" branch. It shouldn't get in the way 
+if you're running a traditional (0.610 or before) Jifty.
+
+=cut
+
+package Jifty::Plugin::Authentication::Password::View;
+use HTML::Entities ();
+use Jifty::View::Declare -base;
+
+template 'signup' => page {
+    title is 'Signup';
+    my ( $action, $next ) = get(qw(action next));
+
+    p {
+        outs(
+            _(  "If you have an OpenID, there's no need to signup (unless you want to, of course).  You can "
+            )
+        );
+        hyperlink( label => _("log in"), url => '/login' );
+        outs( _(" with it now!") );
+    };
+
+    Jifty->web->form->start( call => $next );
+    render_param( $action => $_ ) for ( $action->argument_names );
+    form_submit( label => _('Signup'), submit => $action );
+    Jifty->web->form->end();
+};
+
+template login => page {
+    { title is 'Login!' };
+    show('login_widget');
+};
+
+template login_widget => sub {
+
+    my ( $action, $next ) = get( 'action', 'next' );
+    $action ||= new_action( class => 'Login' );
+    $next ||= Jifty::Continuation->new(
+        request => Jifty::Request->new( path => "/" ) );
+    unless ( Jifty->web->current_user->id ) {
+        p {
+            outs( _(        qq{No account yet? It's quick and easy.} ));
+            tangent( label => _("Sign up for an account!"), url   => '/signup');
+        };
+        h3  { _(qq{Login with a password}) };
+        div {
+            attr { id => 'jifty-login' };
+            Jifty->web->form->start( call => $next );
+            render_param( $action, 'email', focus => 1 );
+            render_param( $action, $_ ) for (qw(password remember));
+            form_submit( label => _(q{Login}), submit => $action );
+            hyperlink(
+                label => _("Lost your password?"),
+                url   => "/lost_password"
+            );
+            Jifty->web->form->end();
+        };
+    } else {
+        outs( _("You're already logged in.") );
+    }
+};
+
+template 'let/reset_lost_password' => page {
+    attr { title => 'Reset lost password' };
+    my $action = Jifty->web->new_action( class => 'ResetLostPassword' );
+
+    h2   { _('Reset lost password') };
+    form {
+        render_param( $action => $_ ) for ( $action->argument_names );
+        form_submit( label => _("New password") );
+    };
+};
+
+template 'let/confirm_email' => sub {
+    new_action( class => 'ConfirmEmail' )->run;
+    redirect("/");
+};
+
+template 'lost_password' => page {
+    my $action = Jifty->web->new_action(
+        moniker => 'password_reminder',
+        class   => 'SendPasswordReminder',
+    );
+
+    h2 { _('Send a link to reset your password') };
+    outs( _(  "You lost your password. A link to reset it will be sent to the following email address:"));
+
+    form {
+        render_param( $action => $_ ) for ( $action->argument_names );
+        form_submit( label => _("Send") );
+        }
+
+};
+
+template 'passwordreminder' => page {
+    attr { title => 'Send Password Reminder' };
+    my $action = Jifty->web->new_action(
+        moniker => 'password_reminder',
+        class   => 'SendPasswordReminder',
+    );
+    h2 { _('Send a password reminder') };
+    p  { _(  "You lost your password. A reminder will be send to the following mail:") };
+
+    form {
+        render_param( $action => $_ ) for ( $action->argument_names );
+        form_submit( label => _("Send") );
+    };
+};
+
+1;

Added: jifty/trunk/lib/Jifty/Plugin/LetMe.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/LetMe.pm	Tue Mar 13 14:12:17 2007
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::LetMe;
+use base qw/Jifty::Plugin/;
+
+# Your plugin goes here.  If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+=head1 NAME
+
+Jifty::Plugin::LetMe
+
+=head1 DESCRIPTION
+
+This plugin provides dispatcher rules to support jifty's internal C<LetMe> 
+url-based authentication.  
+
+
+=cut
+
+1;


More information about the Jifty-commit mailing list