View | Details | Raw Unified | Return to bug 8515
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-passwd.tt (-5 / +5 lines)
Lines 26-43 Link Here
26
        </p></div>
26
        </p></div>
27
    [% END %]
27
    [% END %]
28
    
28
    
29
    [% IF ( Ask_data ) %]
29
    [% IF ( OpacPasswordChange ) %]
30
        [% IF ( OpacPasswordChange ) %]
30
        [% IF ( Ask_data ) %]
31
        <form action="/cgi-bin/koha/opac-passwd.pl" name="mainform" id="mainform" method="post"><fieldset class="brief">
31
        <form action="/cgi-bin/koha/opac-passwd.pl" name="mainform" id="mainform" method="post"><fieldset class="brief">
32
			[% UNLESS ( ShortPass ) %]<div class="hint">Your password must be at least [% minpasslen %] characters long.</div>[% END %]
32
			[% UNLESS ( ShortPass ) %]<div class="hint">Your password must be at least [% minpasslen %] characters long.</div>[% END %]
33
          <ol>  <li><label for="Oldkey">Current password:</label> <input type="password" id="Oldkey" size="25"  name="Oldkey" /></li>
33
          <ol>  <li><label for="Oldkey">Current password:</label> <input type="password" id="Oldkey" size="25"  name="Oldkey" /></li>
34
            <li><label for="Newkey">New password:</label> <input type="password" id="Newkey"  size="25"  name="Newkey" /></li>
34
            <li><label for="Newkey">New password:</label> <input type="password" id="Newkey"  size="25"  name="Newkey" /></li>
35
            <li><label for="Confirm">Re-type new password:</label> <input type="password"  id="Confirm" size="25" name="Confirm" /></li></ol></fieldset>
35
            <li><label for="Confirm">Re-type new password:</label> <input type="password"  id="Confirm" size="25" name="Confirm" /></li></ol></fieldset>
36
            <fieldset class="action"><input type="submit" value="Submit changes" class="submit" /> <a href="/cgi-bin/koha/opac-user.pl" class="cancel">Cancel</a></fieldset>
36
            <fieldset class="action"><input type="submit" value="Submit changes" class="submit" /> <a href="/cgi-bin/koha/opac-user.pl" class="cancel">Cancel</a></fieldset>
37
    </form>
37
        </form>
38
        [% ELSE %]
39
            <div class="dialog alert">You can't change your password.</div>
40
        [% END %]
38
        [% END %]
39
    [% ELSE %]
40
        <div class="dialog alert">You can't change your password.</div>
41
    [% END %]
41
    [% END %]
42
    
42
    
43
    [% IF ( password_updated ) %]
43
    [% IF ( password_updated ) %]
(-)a/opac/opac-passwd.pl (-41 / +41 lines)
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
- 

Return to bug 8515