# First, if _password is blank, generate one and set default encoding.
if ( ! $recref->{_password} ) {
- $self->set_password('');
+ $error = $self->set_password('');
}
# But if there's a _password but no encoding, assume it's plaintext and
# set it to default encoding.
elsif ( ! $recref->{_password_encoding} ) {
- $self->set_password($recref->{_password});
+ $error = $self->set_password($recref->{_password});
}
+ return $error if $error;
# Next, check _password to ensure compliance with the encoding.
if ( $recref->{_password_encoding} eq 'ldap' ) {
$recref->{_password} =~ /\!/ and return gettext('illegal_password');
}
}
- elsif ( $recref->{_password_encoding} eq 'legacy' ) {
- # this happens when set_password fails
- return gettext('illegal_password'). " $passwordmin-$passwordmax ".
- FS::Msgcat::_gettext('illegal_password_characters').
- ": ". $recref->{_password};
+ else {
+ return "invalid password encoding ('".$recref->{_password_encoding}."'";
}
$self->SUPER::check;
my $self = shift;
my $pass = shift;
my ($encoding, $encryption);
+ my $failure = gettext('illegal_password'). " $passwordmin-$passwordmax ".
+ FS::Msgcat::_gettext('illegal_password_characters').
+ ": ". $pass;
+ if(($passwordmin and length($pass) < $passwordmin) or
+ ($passwordmax and length($pass) > $passwordmax)) {
+ return $failure;
+ }
if($self->_password_encoding) {
$encoding = $self->_password_encoding;
$self->_password_encoding('crypt');
}
else {
- # do nothing; check() will recognize this as an error
+ return $failure;
}
}
}
$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!";
my $svcnum = $1;
+my $error;
my $old;
if ( $svcnum ) {
die "fatal: no previous account to recall hidden password from!" unless $old;
}
else {
- $new->set_password($cgi->param('clear_password'));
+ $error = $new->set_password($cgi->param('clear_password'));
}
-my $error;
if ( $svcnum ) {
foreach (grep { $old->$_ != $new->$_ } qw( seconds upbytes downbytes totalbytes )) {
my %hash = map { $_ => $new->$_ }
<SCRIPT TYPE="text/javascript">
function randomPass() {
var i=0;
- var pw_set='<% join('', 'a'..'z', 'A'..'Z', '0'..'9', '.', '/') %>';
+ var pw_set='<% join('', 'a'..'z', 'A'..'Z', '0'..'9' ) %>';
var pass='';
while(i < 8) {
i++;
<TD ALIGN="right">Password</TD>
<TD>
<INPUT TYPE="text" NAME="clear_password" VALUE="<% $password %>" SIZE=<% $pmax2 %> MAXLENGTH=<% $pmax %>>
- <INPUT TYPE="button" VALUE="Randomize" onclick="randomPass();">
+ <INPUT TYPE="button" VALUE="Generate" onclick="randomPass();">
</TD>
</TR>
%}else{