Lines 24-38
use CGI qw ( -utf8 );
Link Here
|
24 |
|
24 |
|
25 |
use C4::Auth; # checkauth, getborrowernumber. |
25 |
use C4::Auth; # checkauth, getborrowernumber. |
26 |
use C4::Context; |
26 |
use C4::Context; |
27 |
use Digest::MD5 qw(md5_base64); |
|
|
28 |
use C4::Circulation; |
27 |
use C4::Circulation; |
29 |
use C4::Members; |
28 |
use C4::Members; |
30 |
use C4::Output; |
29 |
use C4::Output; |
31 |
use Koha::AuthUtils qw(hash_password); |
|
|
32 |
use Koha::Patrons; |
30 |
use Koha::Patrons; |
33 |
|
31 |
|
|
|
32 |
use Try::Tiny; |
33 |
|
34 |
my $query = new CGI; |
34 |
my $query = new CGI; |
35 |
my $dbh = C4::Context->dbh; |
|
|
36 |
|
35 |
|
37 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
36 |
my ( $template, $borrowernumber, $cookie ) = get_template_and_user( |
38 |
{ |
37 |
{ |
Lines 60-76
if ( C4::Context->preference("OpacPasswordChange") ) {
Link Here
|
60 |
$template->param( 'Error_messages' => '1' ); |
59 |
$template->param( 'Error_messages' => '1' ); |
61 |
$template->param( 'passwords_mismatch' => '1' ); |
60 |
$template->param( 'passwords_mismatch' => '1' ); |
62 |
} else { |
61 |
} else { |
63 |
my ( $is_valid, $error ) = Koha::AuthUtils::is_password_valid( $new_password ); |
62 |
try { |
64 |
unless ( $is_valid ) { |
|
|
65 |
$error = 'password_too_short' if $error eq 'too_short'; |
66 |
$error = 'password_too_weak' if $error eq 'too_weak'; |
67 |
$error = 'password_has_whitespaces' if $error eq 'has_whitespaces'; |
68 |
} else { |
69 |
# Password is valid and match |
70 |
$patron->set_password( $new_password ); |
63 |
$patron->set_password( $new_password ); |
71 |
$template->param( 'password_updated' => '1' ); |
64 |
$template->param( 'password_updated' => '1' ); |
72 |
$template->param( 'borrowernumber' => $borrowernumber ); |
65 |
$template->param( 'borrowernumber' => $borrowernumber ); |
73 |
} |
66 |
} |
|
|
67 |
catch { |
68 |
$error = 'password_too_short' |
69 |
if $_->isa('Koha::Exceptions::Password::TooShort'); |
70 |
$error = 'password_too_weak' |
71 |
if $_->isa('Koha::Exceptions::Password::TooWeak'); |
72 |
$error = 'password_has_whitespaces' |
73 |
if $_->isa('Koha::Exceptions::Password::WhitespaceCharacters'); |
74 |
}; |
74 |
} |
75 |
} |
75 |
} |
76 |
} |
76 |
else { |
77 |
else { |
77 |
- |
|
|