From f07df483ee9e755f29fe599424a1ba2ed8bcc6b8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 18 Jan 2011 16:31:51 +0100 Subject: [PATCH] =?utf8?q?=C3=9Cberpr=C3=BCfung=20der=20Passwortrichtlinie?= =?utf8?q?,=20wenn=20die=20Benutzerin=20ihr=20Passwort=20=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/AM.pm | 12 +----------- bin/mozilla/am.pl | 23 ++++++++++++++++++++++- locale/de/all | 1 + 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index df7d9d2c0..e6101b402 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1410,7 +1410,7 @@ sub save_defaults { sub save_preferences { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $form, $webdav) = @_; + my ($self, $myconfig, $form) = @_; my $dbh = $form->get_standard_dbh($myconfig); @@ -1438,16 +1438,6 @@ sub save_preferences { my $auth = $main::auth; - if ($auth->can_change_password() - && defined $form->{new_password} - && ($form->{new_password} ne '********')) { - $auth->change_password($form->{login}, $form->{new_password}); - - $form->{password} = $form->{new_password}; - $auth->set_session_value('password', $form->{password}); - $auth->create_or_refresh_session(); - } - $main::lxdebug->leave_sub(); return $rc; diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index b7c980c9e..66874c736 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -34,6 +34,7 @@ use utf8; use SL::Auth; +use SL::Auth::PasswordPolicy; use SL::AM; use SL::CA; use SL::Form; @@ -2549,7 +2550,27 @@ sub save_preferences { TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } }); - $form->redirect($locale->text('Preferences saved!')) if (AM->save_preferences(\%myconfig, \%$form, 0)); + if (AM->save_preferences(\%myconfig, $form)) { + if ($::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}); + + if ($result != SL::Auth::PasswordPolicy->OK()) { + $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result))); + } + + $::auth->change_password($form->{login}, $form->{new_password}); + + $form->{password} = $form->{new_password}; + $::auth->set_session_value('password', $form->{password}); + $::auth->create_or_refresh_session(); + } + + $form->redirect($locale->text('Preferences saved!')); + } + $form->error($locale->text('Cannot save preferences!')); $main::lxdebug->leave_sub(); diff --git a/locale/de/all b/locale/de/all index 00d74fdbb..4951e6de8 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1704,6 +1704,7 @@ $self->{texts} = { 'The selected warehouse does not exist.' => 'Das ausgewählte Lager existiert nicht.', 'The selected warehouse is empty.' => 'Das ausgewählte Lager ist leer.', 'The session is invalid or has expired.' => 'Sie sind von Lx-Office abgemeldet.', + 'The settings were saved, but the password was not changed.' => 'Die Einstellungen wurden gespeichert, aber das Passwort wurde nicht geƤndert.', 'The source warehouse does not contain any bins.' => 'Das Quelllager enthält keine Lagerplätze.', 'The start date is missing.' => 'Das Startdatum fehlt.', 'The subject is missing.' => 'Der Betreff fehlt.', -- 2.20.1