[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.4-158-g817caf4

Shawn Moore sartak at bestpractical.com
Mon Oct 18 04:43:49 EDT 2010


The branch, 3.9-trunk has been updated
       via  817caf407101df55a94a4f202aec7e8af586a1c4 (commit)
       via  357a4f5c3ae08457cb832ed9acc98ff88c8447e7 (commit)
      from  7e4680b17a3d4924ca7e1311c94958951c3e2b0c (commit)

Summary of changes:
 lib/RT/User_Overlay.pm         |   31 ++++++++++++++++++++++++++-----
 share/html/Install/Basics.html |    9 ++++++++-
 2 files changed, 34 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 357a4f5c3ae08457cb832ed9acc98ff88c8447e7
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Oct 18 15:52:55 2010 +0900

    Factor out ValidatePassword

diff --git a/lib/RT/User_Overlay.pm b/lib/RT/User_Overlay.pm
index ab21147..2aa3ac9 100755
--- a/lib/RT/User_Overlay.pm
+++ b/lib/RT/User_Overlay.pm
@@ -142,9 +142,10 @@ sub Create {
         delete $args{'CryptedPassword'};
     } elsif ( !$args{'Password'} ) {
         $args{'Password'} = '*NO-PASSWORD*';
-    } elsif ( length( $args{'Password'} ) < RT->Config->Get('MinimumPasswordLength') ) {
-        return ( 0, $self->loc("Password needs to be at least [_1] characters long",RT->Config->Get('MinimumPasswordLength')) );
     } else {
+        my ($ok, $msg) = $self->ValidatePassword($args{'Password'});
+        return ($ok, $msg) if !$ok;
+
         $args{'Password'} = $self->_GeneratePassword($args{'Password'});
     }
 
@@ -257,6 +258,24 @@ sub Create {
     return ( $id, $self->loc('User created') );
 }
 
+=head2 ValidatePassword STRING
+
+Returns either (0, "failure reason") or 1 depending on whether the given
+password is valid.
+
+=cut
+
+sub ValidatePassword {
+    my $self = shift;
+    my $password = shift;
+
+    if ( length($password) < RT->Config->Get('MinimumPasswordLength') ) {
+        return ( 0, $self->loc("Password needs to be at least [_1] characters long", RT->Config->Get('MinimumPasswordLength')) );
+    }
+
+    return 1;
+}
+
 =head2 SetPrivileged BOOL
 
 If passed a true value, makes this user a member of the "Privileged"  PseudoGroup.
@@ -784,12 +803,14 @@ sub SetPassword {
 
     if ( !$password ) {
         return ( 0, $self->loc("No password set") );
-    } elsif ( length($password) < RT->Config->Get('MinimumPasswordLength') ) {
-        return ( 0, $self->loc("Password needs to be at least [_1] characters long", RT->Config->Get('MinimumPasswordLength')) );
     } else {
+        my ($val, $msg) = $self->ValidatePassword($password);
+        return ($val, $msg) if !$val;
+
         my $new = !$self->HasPassword;
         $password = $self->_GeneratePassword($password);
-        my ( $val, $msg ) = $self->_Set(Field => 'Password', Value => $password);
+
+        ( $val, $msg ) = $self->_Set(Field => 'Password', Value => $password);
         if ($val) {
             return ( 1, $self->loc("Password set") ) if $new;
             return ( 1, $self->loc("Password changed") );

commit 817caf407101df55a94a4f202aec7e8af586a1c4
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Oct 18 17:42:16 2010 +0900

    Validate admin password and show errors to the user

diff --git a/share/html/Install/Basics.html b/share/html/Install/Basics.html
index 1792eff..0fce4e2 100644
--- a/share/html/Install/Basics.html
+++ b/share/html/Install/Basics.html
@@ -81,9 +81,16 @@ if ( $Run ) {
         push @errors, loc("Invalid [_1]: it should be a number", 'WebPort');
     }
 
-    unless ( $ARGS{Password} ) {
+    if ( !$ARGS{Password} ) {
         push @errors, loc("You must enter an Administrative password");
     }
+    else {
+        my $dummy_user = RT::User->new($session{CurrentUser});
+        my ($ok, $msg) = $dummy_user->ValidatePassword($ARGS{Password});
+        unless ($ok) {
+            push @errors, $msg;
+        }
+    }
 
     if ( $Back ) {
         RT::Interface::Web::Redirect(RT->Config->Get('WebURL') .

-----------------------------------------------------------------------


More information about the Rt-commit mailing list