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

(-)a/C4/Passwordrecovery.pm (-3 / +2 lines)
Lines 19-25 package C4::Passwordrecovery; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use C4::Context;
21
use C4::Context;
22
use Math::Random::Secure;
22
use Crypt::Eksblowfish::Bcrypt qw(en_base64);
23
23
24
use vars qw($VERSION @ISA @EXPORT);
24
use vars qw($VERSION @ISA @EXPORT);
25
25
Lines 111-118 sub SendPasswordRecoveryEmail { Link Here
111
111
112
    # generate UUID
112
    # generate UUID
113
    my @chars = ( "A" .. "Z", "a" .. "z", "0" .. "9" );
113
    my @chars = ( "A" .. "Z", "a" .. "z", "0" .. "9" );
114
    my $uuid_str;
114
    my $uuid_str = '$2a$08$'.en_base64(Koha::AuthUtils::generate_salt('weak', 16));
115
    $uuid_str .= $chars[ rand @chars ] for 1 .. 32;
116
115
117
    # insert into database
116
    # insert into database
118
    my $expirydate =
117
    my $expirydate =
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-password-recovery.tt (-26 / +16 lines)
Lines 1-6 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% INCLUDE 'doc-head-open.inc' %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog</title>
3
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %] - Forgotten password recovery[% ELSE %]Koha online[% END %] catalog - Forgotten password recovery</title>
4
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% BLOCK cssinclude %][% END %]
5
[% BLOCK cssinclude %][% END %]
6
[% BLOCK jsinclude %]
6
[% BLOCK jsinclude %]
Lines 30-36 Link Here
30
<div class="main">
30
<div class="main">
31
    <ul class="breadcrumb">
31
    <ul class="breadcrumb">
32
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
32
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
33
        <li><a href="#">Change your password</a></li>
33
        <li><a href="#">Forgotten password recovery</a></li>
34
    </ul>
34
    </ul>
35
35
36
    <div class="container-fluid">
36
    <div class="container-fluid">
Lines 44-83 Link Here
44
                [% END %]
44
                [% END %]
45
            </div>
45
            </div>
46
            <div class="span10">
46
            <div class="span10">
47
                    <h3>Password recovery</h3>
47
                    <h3>Forgotten password recovery</h3>
48
            [% IF (hasError) %]
48
            [% IF (hasError) %]
49
                <div class="alert alert-warning">
49
                <div class="alert alert-warning">
50
                    <h3>An error occurred</h3>
50
                    <h3>Oops!</h3>
51
                    <p>
51
                    <p>
52
                    [% IF (sendmailError) %]
52
                    [% IF (sendmailError) %]
53
                        An error has occurred while sending you the password recovery link.
53
                        An error has occurred while sending you the password recovery link.
54
                        <br/>Please try again later.
54
                        <br/>Please try again later.
55
                    [% ELSIF (errNoBorrowerFound) %]
55
                    [% ELSIF (errNoBorrowerFound) %]
56
                        No account was found with the provided information.
56
                        No account was found with the provided information.
57
                        <br/>Check if you typed it correctly.
58
                    [% ELSIF (errBadEmail) %]
59
                        The provided email address is not tied to this account.
60
                    [% ELSIF (errTooManyEmailFound) %]
61
                        More than one account has been found for the email address: "<strong>[% email %]</strong>"
62
                        <br/>Try to use your username or an alternative email if you have one.
63
                    [% ELSIF (errNoBorrowerEmail) %]
64
                        This account has no email address we can send the email to.
65
                    [% ELSIF (errAlreadyStartRecovery) %]
57
                    [% ELSIF (errAlreadyStartRecovery) %]
66
                        The process of password recovery has already started for this account ("<strong>[% username %]</strong>")
58
                        The process of password recovery has already been started for this account ("<strong>[% username %]</strong>")
67
                        <br/>Check your emails; you should receive the link to reset your password.
59
                        <br/>You should have received an email with a link to reset your password.
68
                        <br/>If you did not receive it, click <a href="/cgi-bin/koha/opac-password-recovery.pl?resendEmail=true&email=[% email %]&username=[% username %]">here</a> to get a new password recovery link.
60
                        <br/>If you did not receive this email, you can <a href="/cgi-bin/koha/opac-password-recovery.pl?resendEmail=true&email=[% email %]&username=[% username %]">request a new password recovery link.</a>
69
                    [% ELSIF (errPassNotMatch) %]
61
                    [% ELSIF (errPassNotMatch) %]
70
                        The passwords entered does not match.
62
                        Oops! The passwords must match.
71
                        <br/>Please try again.
72
                    [% ELSIF (errPassTooShort) %]
63
                    [% ELSIF (errPassTooShort) %]
73
                        The password is too short.
64
                        Your chosen password is too short.
74
                        <br/>The password must contain at least [% minPassLength %] characters.
65
                        <br/>The password must contain at least [% minPassLength %] characters.
75
                    [% ELSIF (errLinkNotValid) %]
66
                    [% ELSIF (errLinkNotValid) %]
76
                        We could not authenticate you as the account owner.
67
                        The link you clicked is either invalid, or expired.
77
                        <br/>Be sure to use the link you received in your email.
68
                        <br/>Be sure you used the link from the email, or contact library staff for assistance.
78
                    [% END %]
69
                    [% END %]
79
                    </p>
70
                    </p>
80
                    <p>Please contact the staff if you need further assistance.</p>
71
                    <p>Please contact the library if you need further assistance.</p>
81
                </div>
72
                </div>
82
            [% END %]
73
            [% END %]
83
                <div id="password-recovery">
74
                <div id="password-recovery">
Lines 87-94 Link Here
87
                    <form action="/cgi-bin/koha/opac-password-recovery.pl" method="post">
78
                    <form action="/cgi-bin/koha/opac-password-recovery.pl" method="post">
88
                        <input type="hidden" name="koha_login_context" value="opac" />
79
                        <input type="hidden" name="koha_login_context" value="opac" />
89
                        <fieldset>
80
                        <fieldset>
90
                            <p>To reset your password, enter your username or email address.
81
                            <p>To reset your password, enter your login and email address.
91
                            <br/>A link to reset your password will be sent at this address.</p>
92
                            <label for="username">Login:</label>
82
                            <label for="username">Login:</label>
93
                            <input type="text" id="username" size="40" name="username" value="[% username %]" />
83
                            <input type="text" id="username" size="40" name="username" value="[% username %]" />
94
                            <label for="email">Email:</label>
84
                            <label for="email">Email:</label>
Lines 118-127 Link Here
118
                    <div class="alert alert-info">
108
                    <div class="alert alert-info">
119
                        <p>
109
                        <p>
120
                            An email has been sent to "[% email %]".
110
                            An email has been sent to "[% email %]".
121
                            <br/>It contains a link to create a new password.
111
                            <br/>Please click the link in this email to finish the process of resetting your password.
122
                            <br/>This link will be valid for 2 days starting now.
112
                            <br/>This link is valid for 2 days starting now.
123
                        </p>
113
                        </p>
124
                        Click <a href="/cgi-bin/koha/opac-main.pl"">here</a> to return to the main page.
114
                        <a href="/cgi-bin/koha/opac-main.pl"">Return to the main page</a>
125
                    </div>
115
                    </div>
126
[% ELSIF (password_reset_done) %]
116
[% ELSIF (password_reset_done) %]
127
                    <div class="alert alert-success">
117
                    <div class="alert alert-success">
(-)a/opac/opac-password-recovery.pl (-8 / +3 lines)
Lines 64-77 if ( $query->param('sendEmail') || $query->param('resendEmail') ) { Link Here
64
    elsif ($email) {
64
    elsif ($email) {
65
        $search_results = [ Koha::Borrowers->search( { -or => { email => $email, emailpro => $email, B_email  => $email } } ) ];
65
        $search_results = [ Koha::Borrowers->search( { -or => { email => $email, emailpro => $email, B_email  => $email } } ) ];
66
    }
66
    }
67
    if ( not $search_results ) {
67
    if ( not $search_results || scalar @$search_results > 1 ) {
68
        $hasError           = 1;
68
        $hasError           = 1;
69
        $errNoBorrowerFound = 1;
69
        $errNoBorrowerFound = 1;
70
    }
70
    }
71
    elsif ( scalar @$search_results > 1 ) {    # Many matching borrowers
72
        $hasError             = 1;
73
        $errTooManyEmailFound = 1;
74
    }
75
    elsif ( $borrower = shift @$search_results ) {    # One matching borrower
71
    elsif ( $borrower = shift @$search_results ) {    # One matching borrower
76
        $username ||= $borrower->userid;
72
        $username ||= $borrower->userid;
77
        my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email );
73
        my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email );
Lines 79-85 if ( $query->param('sendEmail') || $query->param('resendEmail') ) { Link Here
79
        # Is the given email one of the borrower's ?
75
        # Is the given email one of the borrower's ?
80
        if ( $email && !( grep { $_ eq $email } @emails ) ) {
76
        if ( $email && !( grep { $_ eq $email } @emails ) ) {
81
            $hasError    = 1;
77
            $hasError    = 1;
82
            $errBadEmail = 1;
78
            $errNoBorrowerFound = 1;
83
        }
79
        }
84
80
85
# If we dont have an email yet. Get one of the borrower's email or raise an error.
81
# If we dont have an email yet. Get one of the borrower's email or raise an error.
Lines 88-94 if ( $query->param('sendEmail') || $query->param('resendEmail') ) { Link Here
88
# It's supposed to get a non-empty string from the @emails array. There's surely a simpler way
84
# It's supposed to get a non-empty string from the @emails array. There's surely a simpler way
89
        elsif ( !$email && !( $email = shift [ grep { length() } @emails ] ) ) {
85
        elsif ( !$email && !( $email = shift [ grep { length() } @emails ] ) ) {
90
            $hasError           = 1;
86
            $hasError           = 1;
91
            $errNoBorrowerEmail = 1;
87
            $errNoBorrowerFound = 1;
92
        }
88
        }
93
89
94
# Check if a password reset already issued for this borrower AND we are not asking for a new email
90
# Check if a password reset already issued for this borrower AND we are not asking for a new email
95
- 

Return to bug 8753