Lines 46-102
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
46 |
|
46 |
|
47 |
# get borrower information .... |
47 |
# get borrower information .... |
48 |
my ( $borr ) = GetMemberDetails( $borrowernumber ); |
48 |
my ( $borr ) = GetMemberDetails( $borrowernumber ); |
49 |
my $sth = $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?"); |
|
|
50 |
my $minpasslen = C4::Context->preference("minPasswordLength"); |
49 |
my $minpasslen = C4::Context->preference("minPasswordLength"); |
51 |
if ( $query->param('Oldkey') |
50 |
if ( C4::Context->preference("OpacPasswordChange") ) { |
52 |
&& $query->param('Newkey') |
51 |
my $sth = $dbh->prepare("UPDATE borrowers SET password = ? WHERE borrowernumber=?"); |
53 |
&& $query->param('Confirm') ) |
52 |
if ( $query->param('Oldkey') |
54 |
{ |
53 |
&& $query->param('Newkey') |
55 |
if ( goodkey( $dbh, $borrowernumber, $query->param('Oldkey') ) ) { |
54 |
&& $query->param('Confirm') ) |
56 |
if ( $query->param('Newkey') eq $query->param('Confirm') |
55 |
{ |
57 |
&& length( $query->param('Confirm') ) >= $minpasslen ) |
56 |
if ( goodkey( $dbh, $borrowernumber, $query->param('Oldkey') ) ) { |
58 |
{ # Record password |
57 |
if ( $query->param('Newkey') eq $query->param('Confirm') |
59 |
my $clave = md5_base64( $query->param('Newkey') ); |
58 |
&& length( $query->param('Confirm') ) >= $minpasslen ) |
60 |
$sth->execute( $clave, $borrowernumber ); |
59 |
{ # Record password |
61 |
$template->param( 'password_updated' => '1' ); |
60 |
my $clave = md5_base64( $query->param('Newkey') ); |
62 |
$template->param( 'borrowernumber' => $borrowernumber ); |
61 |
$sth->execute( $clave, $borrowernumber ); |
|
|
62 |
$template->param( 'password_updated' => '1' ); |
63 |
$template->param( 'borrowernumber' => $borrowernumber ); |
64 |
} |
65 |
elsif ( $query->param('Newkey') ne $query->param('Confirm') ) { |
66 |
$template->param( 'Ask_data' => '1' ); |
67 |
$template->param( 'Error_messages' => '1' ); |
68 |
$template->param( 'PassMismatch' => '1' ); |
69 |
} |
70 |
elsif ( length( $query->param('Confirm') ) < $minpasslen ) { |
71 |
$template->param( 'Ask_data' => '1' ); |
72 |
$template->param( 'Error_messages' => '1' ); |
73 |
$template->param( 'ShortPass' => '1' ); |
74 |
} |
75 |
else { |
76 |
$template->param( 'Error_messages' => '1' ); |
77 |
} |
63 |
} |
78 |
} |
64 |
elsif ( $query->param('Newkey') ne $query->param('Confirm') ) { |
79 |
else { |
65 |
$template->param( 'Ask_data' => '1' ); |
80 |
$template->param( 'Ask_data' => '1' ); |
66 |
$template->param( 'Error_messages' => '1' ); |
81 |
$template->param( 'Error_messages' => '1' ); |
67 |
$template->param( 'PassMismatch' => '1' ); |
82 |
$template->param( 'WrongPass' => '1' ); |
68 |
} |
83 |
} |
69 |
elsif ( length( $query->param('Confirm') ) < $minpasslen ) { |
84 |
} |
70 |
$template->param( 'Ask_data' => '1' ); |
85 |
else { |
|
|
86 |
|
87 |
# Called Empty, Ask for data. |
88 |
$template->param( 'Ask_data' => '1' ); |
89 |
if (!$query->param('Oldkey') && ($query->param('Newkey') || $query->param('Confirm'))){ |
90 |
# Old password is empty but one of the others isnt |
71 |
$template->param( 'Error_messages' => '1' ); |
91 |
$template->param( 'Error_messages' => '1' ); |
72 |
$template->param( 'ShortPass' => '1' ); |
92 |
$template->param( 'WrongPass' => '1' ); |
73 |
} |
93 |
} |
74 |
else { |
94 |
elsif ($query->param('Oldkey') && (!$query->param('Newkey') || !$query->param('Confirm'))){ |
|
|
95 |
# Oldpassword is entered but one of the other fields is empty |
75 |
$template->param( 'Error_messages' => '1' ); |
96 |
$template->param( 'Error_messages' => '1' ); |
|
|
97 |
$template->param( 'PassMismatch' => '1' ); |
76 |
} |
98 |
} |
77 |
} |
99 |
} |
78 |
else { |
|
|
79 |
$template->param( 'Ask_data' => '1' ); |
80 |
$template->param( 'Error_messages' => '1' ); |
81 |
$template->param( 'WrongPass' => '1' ); |
82 |
} |
83 |
} |
84 |
else { |
85 |
|
86 |
# Called Empty, Ask for data. |
87 |
$template->param( 'Ask_data' => '1' ); |
88 |
if (!$query->param('Oldkey') && ($query->param('Newkey') || $query->param('Confirm'))){ |
89 |
# Old password is empty but one of the others isnt |
90 |
$template->param( 'Error_messages' => '1' ); |
91 |
$template->param( 'WrongPass' => '1' ); |
92 |
} |
93 |
elsif ($query->param('Oldkey') && (!$query->param('Newkey') || !$query->param('Confirm'))){ |
94 |
# Oldpassword is entered but one of the other fields is empty |
95 |
$template->param( 'Error_messages' => '1' ); |
96 |
$template->param( 'PassMismatch' => '1' ); |
97 |
} |
98 |
} |
100 |
} |
99 |
|
|
|
100 |
$template->param(firstname => $borr->{'firstname'}, |
101 |
$template->param(firstname => $borr->{'firstname'}, |
101 |
surname => $borr->{'surname'}, |
102 |
surname => $borr->{'surname'}, |
102 |
minpasslen => $minpasslen, |
103 |
minpasslen => $minpasslen, |
103 |
- |
|
|