From 3ccbb380d0d3158874cd55b8e913dcc9ea2f7d76 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Jan 2010 10:05:09 +0000 Subject: [PATCH] more fallout from default pw encryption: fix error reporting when entering a bad password --- FS/FS/svc_acct.pm | 13 +++++++------ httemplate/edit/process/svc_acct.cgi | 21 ++++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index ca33aa858..f965e8dff 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -1333,11 +1333,14 @@ is >0), one will be generated randomly. sub set_password { my( $self, $pass ) = ( shift, shift ); + warn "[$me] set_password (to $pass) called on $self: ". Dumper($self) + if $DEBUG; + my $failure = gettext('illegal_password'). " $passwordmin-$passwordmax ". FS::Msgcat::_gettext('illegal_password_characters'). ": ". $pass; - my ($encoding, $encryption); + my( $encoding, $encryption ) = ('', ''); if ( $self->_password_encoding ) { $encoding = $self->_password_encoding; @@ -1357,7 +1360,7 @@ sub set_password { $self->_password_encoding($encoding); } - if( $encoding eq 'legacy' ) { + if ( $encoding eq 'legacy' ) { # The legacy behavior from check(): # If the password is blank, randomize it and set encoding to 'plain'. @@ -1374,14 +1377,12 @@ sub set_password { $pass = $1.$3; $self->_password_encoding('crypt'); # Various disabled crypt passwords - } elsif ( $pass eq '*' or - $pass eq '!' or - $pass eq '!!' ) { + } elsif ( $pass eq '*' || $pass eq '!' || $pass eq '!!' ) { $self->_password_encoding('crypt'); } else { return $failure; } - } + } $self->_password($pass); return; diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 515d89e91..1712d51a8 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -11,7 +11,6 @@ die "access denied" $cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; my $svcnum = $1; -my $error; my $old; if ( $svcnum ) { @@ -40,27 +39,31 @@ map { } (fields('svc_acct'), qw ( pkgnum svcpart usergroup )); my $new = new FS::svc_acct ( \%hash ); +my $error = ''; + $new->_password($old->_password) if $old; -if( $cgi->param('clear_password') eq '*HIDDEN*' - or $cgi->param('clear_password') =~ /^\(.* encrypted\)$/ ) { +if ( $cgi->param('clear_password') eq '*HIDDEN*' + || $cgi->param('clear_password') =~ /^\(.* encrypted\)$/ ) { die "fatal: no previous account to recall hidden password from!" unless $old; -} -else { +} else { $error = $new->set_password($cgi->param('clear_password')); } if ( $svcnum ) { - foreach (grep { $old->$_ != $new->$_ } qw( seconds upbytes downbytes totalbytes )) { + foreach ( grep { $old->$_ != $new->$_ } + qw( seconds upbytes downbytes totalbytes ) + ) + { my %hash = map { $_ => $new->$_ } grep { $new->$_ } qw( seconds upbytes downbytes totalbytes ); - $error = $new->set_usage(\%hash); #unoverlimit and trigger radius changes - last; #once is enough + $error ||= $new->set_usage(\%hash); #unoverlimit and trigger radius changes + last; #once is enough } $error ||= $new->replace($old); } else { - $error = $new->insert; + $error ||= $new->insert; $svcnum = $new->svcnum; } -- 2.11.0