Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4099d0e8

Von Moritz Bunkus vor fast 14 Jahren hinzugefügt

  • ID 4099d0e8f2d10fecac8bdccb82c900cb7059ab98
  • Vorgänger f07df483
  • Nachfolger 6b352f38

Überprüfung der Passwortrichtlinie, wenn die Administratorin eine Benutzerin ändert

Unterschiede anzeigen:

SL/Auth/PasswordPolicy.pm
19 19
);
20 20

  
21 21
sub verify {
22
  my ($self, $password) = @_;
22
  my ($self, $password, $is_admin) = @_;
23 23

  
24 24
  my $cfg = $self->config;
25 25
  return OK() unless $cfg && %{ $cfg };
26
  return OK() if $is_admin && $cfg->{disable_policy_for_admin};
26 27

  
27 28
  my $result = OK();
28 29
  $result |= TOO_SHORT()            if $cfg->{min_length}                && (length($password) < $cfg->{min_length});
......
144 145

  
145 146
=over 4
146 147

  
147
=item C<verify $password>
148
=item C<verify $password, $is_admin>
148 149

  
149 150
Checks whether or not the password matches the policy. Returns C<OK()>
150 151
if it does and an error code otherwise (binary or'ed of the error
151 152
constants).
152 153

  
154
If C<$is_admin> is trueish and the configuration specifies that the
155
policy checks are disabled for the administrator then C<verify> will
156
always return C<OK()>.
157

  
153 158
=item C<errors $code>
154 159

  
155 160
Returns an array of human-readable strings describing the issues set
bin/mozilla/admin.pl
42 42
use Sys::Hostname;
43 43

  
44 44
use SL::Auth;
45
use SL::Auth::PasswordPolicy;
45 46
use SL::Form;
46 47
use SL::Iconv;
47 48
use SL::Mailer;
......
520 521

  
521 522
  $myconfig->save_member();
522 523

  
523
  if ($main::auth->can_change_password()
524
      && defined $form->{new_password}
525
      && ($form->{new_password} ne '********')) {
526
    $main::auth->change_password($form->{login}, $form->{new_password});
527
  }
528

  
529 524
  $form->{templates}       =~ s|.*/||;
530 525
  $form->{templates}       =  "$main::templates/$form->{templates}";
531 526
  $form->{mastertemplates} =~ s|.*/||;
......
578 573
    }
579 574
  }
580 575

  
581
  $form->redirect($locale->text('User saved!'));
576
  if ($main::auth->can_change_password()
577
      && defined $form->{new_password}
578
      && ($form->{new_password} ne '********')) {
579
    my $verifier = SL::Auth::PasswordPolicy->new;
580
    my $result   = $verifier->verify($form->{new_password}, 1);
581

  
582
    if ($result != SL::Auth::PasswordPolicy->OK()) {
583
      $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result)));
584
    }
582 585

  
586
    $main::auth->change_password($form->{login}, $form->{new_password});
587
  }
588

  
589
  $form->redirect($locale->text('User saved!'));
583 590
}
584 591

  
585 592
sub save_user_as_new {

Auch abrufbar als: Unified diff