[Jifty-commit] r2949 - in jifty/trunk: .
lib/Jifty/Plugin/Authentication/Password/Action
t/TestApp-Plugin-PasswordAuth/etc
t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Mar 12 16:30:17 EDT 2007
Author: jesse
Date: Mon Mar 12 16:30:17 2007
New Revision: 2949
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/Login.pm
jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Model/User.pm
jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml
jifty/trunk/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Bootstrap.pm
Log:
r53367 at pinglin: jesse | 2007-03-12 16:28:38 -0400
* The password auth plugin now lets you login. Next up: Logout.
Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/Login.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/Login.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Action/Login.pm Mon Mar 12 16:30:17 2007
@@ -20,7 +20,7 @@
=cut
sub arguments {
- return( { username => { label => 'Email username',
+ return( { username => { label => 'Username',
mandatory => 1,
ajax_validates => 1,
} ,
@@ -58,8 +58,9 @@
my $self = shift;
my $username = shift;
- my $u = Jifty::Plugin::Authentication::Password::Model::User->new(current_user => Jifty::Plugin::Authentication::Password::CurrentUser->superuser);
+ my $u = Jifty->app_class('Model', 'User')->new(current_user => Jifty->app_class('CurrentUser')->superuser);
$u->load_by_cols( username => $username );
+ warn "Loaded $u with ".$username;
return $self->validation_error(username => 'We do not have an account that matches that username.') unless ($u->id);
return $self->validation_ok('username');
@@ -131,36 +132,48 @@
sub take_action {
my $self = shift;
- my $user = Jifty->app_class('CurrentUser')->new( username => $self->argument_value('username'));
+ warn "1";
+ my $user = Jifty->app_class('Model', 'User')->new(current_user => Jifty->app_class('CurrentUser')->superuser);
+ $user->load_by_cols( username => $self->argument_value('username') );
+
my $password = $self->argument_value('password');
- my $token = $self->argument_value('token') || '';
+ my $token = $self->argument_value('token') || '';
my $hashedpw = $self->argument_value('hashed_password');
- if ($token ne '') { # browser supports javascript, do password hashing
- unless ( $user->id && $user->hashed_password_is($hashedpw, $token)){
- $self->result->error( 'You may have mistyped your username or password. Give it another shot.' );
- return;
- }
- Jifty->web->session->set(login_token => '');
- }
- else { # no password hashing over the wire
- unless ( $user->id && $user->password_is($password)){
- $self->result->error( 'You may have mistyped your username or password. Give it another shot.' );
- return;
- }
- }
+ if ( $token ne '' ) { # browser supports javascript, do password hashing
+ unless ( $user->id && $user->hashed_password_is( $hashedpw, $token ) )
+ {
+ $self->result->error(
+ 'You may have mistyped your username or password. Give it another shot.'
+ );
+ return;
+ }
+ Jifty->web->session->set( login_token => '' );
+ } else { # no password hashing over the wire
+ unless ( $user->id && $user->password_is($password) ) {
+ $self->result->error( 'You may have mistyped your username or password. Give it another shot.'
+ );
+ return;
+ }
+ }
# Set up our login message
- $self->result->message("Welcome back, " . $user->user_object->name . "." );
+ $self->result->message( $self->login_message($user));
# Actually do the signin thing.
- Jifty->web->current_user($user);
- Jifty->web->session->expires($self->argument_value('remember') ? '+1y' : undef);
+ Jifty->web->current_user(Jifty->app_class('CurrentUser')->new( id => $user->id));
+ Jifty->web->session->expires( $self->argument_value('remember') ? '+1y' : undef );
Jifty->web->session->set_cookie;
return 1;
}
+sub login_message {
+ my $self = shift;
+ my $user = shift;
+ return "Welcome back, " . $user->name . "." ;
+}
+
1;
Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Model/User.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Model/User.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Model/User.pm Mon Mar 12 16:30:17 2007
@@ -46,7 +46,6 @@
my $pass = shift;
return undef unless $self->_value('password');
-
my ($hash, $salt) = @{$self->_value('password')};
return 1 if ( $hash eq Digest::MD5::md5_hex($pass . $salt) );
Modified: jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml (original)
+++ jifty/trunk/t/TestApp-Plugin-PasswordAuth/etc/config.yml Mon Mar 12 16:30:17 2007
@@ -16,7 +16,7 @@
DevelMode: 1
L10N:
PoDir: share/po
- LogLevel: INFO
+ LogLevel: DEBUG
Mailer: Sendmail
MailerArgs: []
Modified: jifty/trunk/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Bootstrap.pm
==============================================================================
--- jifty/trunk/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Bootstrap.pm (original)
+++ jifty/trunk/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Bootstrap.pm Mon Mar 12 16:30:17 2007
@@ -1,20 +1,22 @@
use warnings;
use strict;
+
package TestApp::Plugin::PasswordAuth::Bootstrap;
+use base 'Jifty::Bootstrap';
- use base 'Jifty::Bootstrap';
-
sub run {
- my $curuser = TestApp::Plugin::PasswordAuth::CurrentUser->new( _bootstrap => 1 );
- my $user = TestApp::Plugin::PasswordAuth::Model::User->new( current_user => $curuser );
- my ($val,$msg) = $user->create( username => 'gooduser at example.com',
- color => 'gray',
- swallow_type => 'african',
- password => 'secret'
-
-);
+ my $curuser
+ = TestApp::Plugin::PasswordAuth::CurrentUser->new( _bootstrap => 1 );
+ my $user = TestApp::Plugin::PasswordAuth::Model::User->new(
+ current_user => $curuser );
+ my ( $val, $msg ) = $user->create(
+ username => 'gooduser at example.com',
+ color => 'gray',
+ swallow_type => 'african',
+ password => 'secret'
+ );
}
More information about the Jifty-commit
mailing list