);
sub verify {
- my ($self, $password) = @_;
+ my ($self, $password, $is_admin) = @_;
my $cfg = $self->config;
return OK() unless $cfg && %{ $cfg };
+ return OK() if $is_admin && $cfg->{disable_policy_for_admin};
my $result = OK();
$result |= TOO_SHORT() if $cfg->{min_length} && (length($password) < $cfg->{min_length});
=over 4
-=item C<verify $password>
+=item C<verify $password, $is_admin>
Checks whether or not the password matches the policy. Returns C<OK()>
if it does and an error code otherwise (binary or'ed of the error
constants).
+If C<$is_admin> is trueish and the configuration specifies that the
+policy checks are disabled for the administrator then C<verify> will
+always return C<OK()>.
+
=item C<errors $code>
Returns an array of human-readable strings describing the issues set
use Sys::Hostname;
use SL::Auth;
+use SL::Auth::PasswordPolicy;
use SL::Form;
use SL::Iconv;
use SL::Mailer;
$myconfig->save_member();
- if ($main::auth->can_change_password()
- && defined $form->{new_password}
- && ($form->{new_password} ne '********')) {
- $main::auth->change_password($form->{login}, $form->{new_password});
- }
-
$form->{templates} =~ s|.*/||;
$form->{templates} = "$main::templates/$form->{templates}";
$form->{mastertemplates} =~ s|.*/||;
}
}
- $form->redirect($locale->text('User saved!'));
+ if ($main::auth->can_change_password()
+ && defined $form->{new_password}
+ && ($form->{new_password} ne '********')) {
+ my $verifier = SL::Auth::PasswordPolicy->new;
+ my $result = $verifier->verify($form->{new_password}, 1);
+
+ if ($result != SL::Auth::PasswordPolicy->OK()) {
+ $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result)));
+ }
+ $main::auth->change_password($form->{login}, $form->{new_password});
+ }
+
+ $form->redirect($locale->text('User saved!'));
}
sub save_user_as_new {