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

(-)a/C4/Passwordrecovery.pm (-50 / +61 lines)
Lines 19-24 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
23
23
use vars qw($VERSION @ISA @EXPORT);
24
use vars qw($VERSION @ISA @EXPORT);
24
25
Lines 26-37 BEGIN { Link Here
26
    # set the version for version checking
27
    # set the version for version checking
27
    $VERSION = 3.07.00.049;
28
    $VERSION = 3.07.00.049;
28
    require Exporter;
29
    require Exporter;
29
    @ISA    = qw(Exporter);
30
    @ISA = qw(Exporter);
30
    push @EXPORT, qw(
31
    push @EXPORT, qw(
31
        &ValidateBorrowernumber
32
      &ValidateBorrowernumber
32
        &SendPasswordRecoveryEmail
33
      &SendPasswordRecoveryEmail
33
        &GetValidLinkInfo
34
      &GetValidLinkInfo
34
        &CompletePasswordRecovery
35
      &CompletePasswordRecovery
35
    );
36
    );
36
}
37
}
37
38
Lines 60-73 sub ValidateBorrowernumber { Link Here
60
    my $schema = Koha::Database->new->schema;
61
    my $schema = Koha::Database->new->schema;
61
62
62
    my $rs = $schema->resultset('BorrowerPasswordRecovery')->search(
63
    my $rs = $schema->resultset('BorrowerPasswordRecovery')->search(
63
    {
64
        {
64
       borrowernumber => $borrower_number,
65
            borrowernumber => $borrower_number,
65
       valid_until => \'> NOW()'
66
            valid_until    => \'> NOW()'
66
    }, {
67
        },
67
        columns => 'borrowernumber'
68
        { columns => 'borrowernumber' }
68
    });
69
    );
69
70
70
    if ($rs->next){
71
    if ( $rs->next ) {
71
        return 1;
72
        return 1;
72
    }
73
    }
73
74
Lines 82-89 sub ValidateBorrowernumber { Link Here
82
83
83
sub GetValidLinkInfo {
84
sub GetValidLinkInfo {
84
    my ($uniqueKey) = @_;
85
    my ($uniqueKey) = @_;
85
    my $dbh = C4::Context->dbh;
86
    my $dbh         = C4::Context->dbh;
86
    my $query = '
87
    my $query       = '
87
    SELECT borrower_password_recovery.borrowernumber, userid
88
    SELECT borrower_password_recovery.borrowernumber, userid
88
    FROM borrower_password_recovery, borrowers
89
    FROM borrower_password_recovery, borrowers
89
    WHERE borrowers.borrowernumber = borrower_password_recovery.borrowernumber
90
    WHERE borrowers.borrowernumber = borrower_password_recovery.borrowernumber
Lines 97-155 sub GetValidLinkInfo { Link Here
97
98
98
=head2 SendPasswordRecoveryEmail
99
=head2 SendPasswordRecoveryEmail
99
100
100
 It creates an email using the templates and send it to the user, using the specified email
101
 It creates an email using the templates and sends it to the user, using the specified email
101
102
102
=cut
103
=cut
103
104
104
sub SendPasswordRecoveryEmail {
105
sub SendPasswordRecoveryEmail {
105
    my $borrower = shift; # Koha::Borrower
106
    my $borrower  = shift;    # Koha::Borrower
106
    my $userEmail = shift; #to_address (the one specified in the request)
107
    my $userEmail = shift;    #to_address (the one specified in the request)
107
    my $update = shift;
108
    my $update    = shift;
108
109
109
    my $schema = Koha::Database->new->schema;
110
    my $schema = Koha::Database->new->schema;
110
111
111
    # generate UUID
112
    # generate UUID
112
    my @chars = ("A".."Z", "a".."z", "0".."9");
113
    my @chars = ( "A" .. "Z", "a" .. "z", "0" .. "9" );
113
    my $uuid_str;
114
    my $uuid_str;
114
    $uuid_str .= $chars[rand @chars] for 1..32;
115
    $uuid_str .= $chars[ rand @chars ] for 1 .. 32;
115
116
116
    # insert into database
117
    # insert into database
117
    my $expirydate = DateTime->now(time_zone => C4::Context->tz())->add( days => 2 );
118
    my $expirydate =
118
    if($update){
119
      DateTime->now( time_zone => C4::Context->tz() )->add( days => 2 );
119
        my $rs = $schema->resultset('BorrowerPasswordRecovery')->search(
120
    if ($update) {
120
        {
121
        my $rs =
121
            borrowernumber => $borrower->borrowernumber,
122
          $schema->resultset('BorrowerPasswordRecovery')
122
        });
123
          ->search( { borrowernumber => $borrower->borrowernumber, } );
123
        $rs->update({uuid => $uuid_str, valid_until => $expirydate->datetime()});
124
        $rs->update(
124
    } else {
125
            { uuid => $uuid_str, valid_until => $expirydate->datetime() } );
125
         my $rs = $schema->resultset('BorrowerPasswordRecovery')->create({
126
    }
126
            borrowernumber=>$borrower->borrowernumber,
127
    else {
127
            uuid => $uuid_str,
128
        my $rs = $schema->resultset('BorrowerPasswordRecovery')->create(
128
            valid_until=> $expirydate->datetime()
129
            {
129
         });
130
                borrowernumber => $borrower->borrowernumber,
131
                uuid           => $uuid_str,
132
                valid_until    => $expirydate->datetime()
133
            }
134
        );
130
    }
135
    }
131
136
132
    # create link
137
    # create link
133
    my $uuidLink = C4::Context->preference( 'OPACBaseURL' ) . "/cgi-bin/koha/opac-password-recovery.pl?uniqueKey=$uuid_str";
138
    my $uuidLink = C4::Context->preference('OPACBaseURL')
139
      . "/cgi-bin/koha/opac-password-recovery.pl?uniqueKey=$uuid_str";
134
140
135
    # prepare the email
141
    # prepare the email
136
    my $letter = C4::Letters::GetPreparedLetter (
142
    my $letter = C4::Letters::GetPreparedLetter(
137
        module => 'members',
143
        module      => 'members',
138
        letter_code => 'PASSWORD_RESET',
144
        letter_code => 'PASSWORD_RESET',
139
        branchcode => $borrower->branchcode,
145
        branchcode  => $borrower->branchcode,
140
        substitute => {passwordreseturl => $uuidLink, user => $borrower->userid },
146
        substitute =>
147
          { passwordreseturl => $uuidLink, user => $borrower->userid },
141
    );
148
    );
142
149
143
    # define to/from emails
150
    # define to/from emails
144
    my $kohaEmail = C4::Context->preference( 'KohaAdminEmailAddress' ); # from
151
    my $kohaEmail = C4::Context->preference('KohaAdminEmailAddress');    # from
145
152
146
    C4::Letters::EnqueueLetter( {
153
    C4::Letters::EnqueueLetter(
147
         letter => $letter,
154
        {
148
         borrowernumber => $borrower->borrowernumber,
155
            letter                 => $letter,
149
         to_address => $userEmail,
156
            borrowernumber         => $borrower->borrowernumber,
150
         from_address => $kohaEmail,
157
            to_address             => $userEmail,
151
         message_transport_type => 'email',
158
            from_address           => $kohaEmail,
152
    } );
159
            message_transport_type => 'email',
160
        }
161
    );
153
162
154
    return 1;
163
    return 1;
155
}
164
}
Lines 162-171 sub SendPasswordRecoveryEmail { Link Here
162
171
163
=cut
172
=cut
164
173
165
sub CompletePasswordRecovery{
174
sub CompletePasswordRecovery {
166
    my $uniqueKey = shift;
175
    my $uniqueKey = shift;
167
    my $model = Koha::Database->new->schema->resultset('BorrowerPasswordRecovery');
176
    my $model =
168
    my $entry = $model->search({-or => [uuid => $uniqueKey, valid_until => \'< NOW()']});
177
      Koha::Database->new->schema->resultset('BorrowerPasswordRecovery');
178
    my $entry = $model->search(
179
        { -or => [ uuid => $uniqueKey, valid_until => \'< NOW()' ] } );
169
    return $entry->delete();
180
    return $entry->delete();
170
}
181
}
171
182
(-)a/Koha/Schema/Result/BorrowerPasswordRecovery.pm (+2 lines)
Lines 63-66 __PACKAGE__->add_columns( Link Here
63
63
64
64
65
# You can replace this text with custom code or comments, and it will be preserved on regeneration
65
# You can replace this text with custom code or comments, and it will be preserved on regeneration
66
__PACKAGE__->set_primary_key("borrowernumber");
67
66
1;
68
1;
(-)a/opac/opac-password-recovery.pl (-37 / +47 lines)
Lines 9-15 use C4::Koha; Link Here
9
use C4::Members qw(changepassword);
9
use C4::Members qw(changepassword);
10
use C4::Output;
10
use C4::Output;
11
use C4::Context;
11
use C4::Context;
12
use C4::Passwordrecovery qw(SendPasswordRecoveryEmail ValidateBorrowernumber GetValidLinkInfo CompletePasswordRecovery);
12
use C4::Passwordrecovery
13
  qw(SendPasswordRecoveryEmail ValidateBorrowernumber GetValidLinkInfo CompletePasswordRecovery);
13
use Koha::AuthUtils qw(hash_password);
14
use Koha::AuthUtils qw(hash_password);
14
use Koha::Borrowers;
15
use Koha::Borrowers;
15
my $query = new CGI;
16
my $query = new CGI;
Lines 50-97 my $errPassNotMatch; Link Here
50
my $errPassTooShort;
51
my $errPassTooShort;
51
52
52
if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
53
if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
54
53
    #try with the main email
55
    #try with the main email
54
    $email ||= ''; # avoid undef
56
    $email ||= '';    # avoid undef
55
    my $borrower;
57
    my $borrower;
56
    my $search_results;
58
    my $search_results;
59
57
    # Find the borrower by his userid or email
60
    # Find the borrower by his userid or email
58
    if( $username ){
61
    if ($username) {
59
        $search_results = [ Koha::Borrowers->search({ userid => $username }) ];
62
        $search_results = [ Koha::Borrowers->search( { userid => $username } ) ];
60
    }
63
    }
61
    elsif ( $email ){
64
    elsif ($email) {
62
        $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 } } ) ];
63
    }
66
    }
64
    if ( not $search_results ){
67
    if ( not $search_results ) {
65
       $hasError            = 1;
68
        $hasError           = 1;
66
       $errNoBorrowerFound  = 1;
69
        $errNoBorrowerFound = 1;
67
    }
70
    }
68
    elsif(scalar @$search_results > 1){ # Many matching borrowers
71
    elsif ( scalar @$search_results > 1 ) {    # Many matching borrowers
69
       $hasError             = 1;
72
        $hasError             = 1;
70
       $errTooManyEmailFound = 1;
73
        $errTooManyEmailFound = 1;
71
    }
74
    }
72
    elsif( $borrower = shift @$search_results ){ # One matching borrower
75
    elsif ( $borrower = shift @$search_results ) {    # One matching borrower
73
        $username ||= $borrower->userid;
76
        $username ||= $borrower->userid;
74
        my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email );
77
        my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email );
78
75
        # Is the given email one of the borrower's ?
79
        # Is the given email one of the borrower's ?
76
        if( $email && !($email ~~ @emails) ){
80
        if ( $email && !( grep { $_ eq $email } @emails ) ) {
77
             $hasError    = 1;
81
            $hasError    = 1;
78
             $errBadEmail = 1;
82
            $errBadEmail = 1;
79
        }
83
        }
80
        # If we dont have an email yet. Get one of the borrower's email or raise an error.
84
81
        # FIXME: That ugly shift-grep contraption.
85
# If we dont have an email yet. Get one of the borrower's email or raise an error.
82
        # $email = shift [ grep { length() } @emails ]
86
# FIXME: That ugly shift-grep contraption.
83
        # It's supposed to get a non-empty string from the @emails array. There's surely a simpler way
87
# $email = shift [ grep { length() } @emails ]
84
        elsif( !$email && !($email = shift [ grep { length() } @emails ]) ){
88
# It's supposed to get a non-empty string from the @emails array. There's surely a simpler way
85
             $hasError           = 1;
89
        elsif ( !$email && !( $email = shift [ grep { length() } @emails ] ) ) {
86
             $errNoBorrowerEmail = 1;
90
            $hasError           = 1;
91
            $errNoBorrowerEmail = 1;
87
        }
92
        }
88
        # Check if a password reset already issued for this borrower AND we are not asking for a new email
93
89
        elsif( ValidateBorrowernumber( $borrower->borrowernumber ) && !$query->param('resendEmail') ){
94
# Check if a password reset already issued for this borrower AND we are not asking for a new email
95
        elsif ( ValidateBorrowernumber( $borrower->borrowernumber )
96
            && !$query->param('resendEmail') )
97
        {
90
            $hasError                = 1;
98
            $hasError                = 1;
91
            $errAlreadyStartRecovery = 1;
99
            $errAlreadyStartRecovery = 1;
92
        }
100
        }
93
    }
101
    }
94
    else{ # 0 matching borrower
102
    else {    # 0 matching borrower
95
        $hasError           = 1;
103
        $hasError           = 1;
96
        $errNoBorrowerFound = 1;
104
        $errNoBorrowerFound = 1;
97
    }
105
    }
Lines 108-120 if ( $query->param('sendEmail') || $query->param('resendEmail') ) { Link Here
108
            username                => $username
116
            username                => $username
109
        );
117
        );
110
    }
118
    }
111
    elsif ( SendPasswordRecoveryEmail( $borrower, $email, $query->param('resendEmail') ) ) {#generate uuid and send recovery email
119
    elsif ( SendPasswordRecoveryEmail( $borrower, $email, $query->param('resendEmail') ) ) {    # generate uuid and send recovery email
112
        $template->param(
120
        $template->param(
113
            mail_sent => 1,
121
            mail_sent => 1,
114
            email     => $email
122
            email     => $email
115
        );
123
        );
116
    }
124
    }
117
    else {# if it doesn't work....
125
    else {    # if it doesn't work....
118
        $template->param(
126
        $template->param(
119
            password_recovery => 1,
127
            password_recovery => 1,
120
            sendmailError     => 1
128
            sendmailError     => 1
Lines 123-133 if ( $query->param('sendEmail') || $query->param('resendEmail') ) { Link Here
123
}
131
}
124
elsif ( $query->param('passwordReset') ) {
132
elsif ( $query->param('passwordReset') ) {
125
    ( $borrower_number, $username ) = GetValidLinkInfo($uniqueKey);
133
    ( $borrower_number, $username ) = GetValidLinkInfo($uniqueKey);
134
126
    #validate password length & match
135
    #validate password length & match
127
    if (   ($borrower_number)
136
    if (   ($borrower_number)
128
        && ( $password eq $repeatPassword )
137
        && ( $password eq $repeatPassword )
129
        && ( length($password) >= $minPassLength ) )
138
        && ( length($password) >= $minPassLength ) )
130
    {  #apply changes
139
    {    #apply changes
131
        changepassword( $username, $borrower_number, hash_password($password) );
140
        changepassword( $username, $borrower_number, hash_password($password) );
132
        CompletePasswordRecovery($uniqueKey);
141
        CompletePasswordRecovery($uniqueKey);
133
        $template->param(
142
        $template->param(
Lines 135-148 elsif ( $query->param('passwordReset') ) { Link Here
135
            username            => $username
144
            username            => $username
136
        );
145
        );
137
    }
146
    }
138
    else { #errors
147
    else {    #errors
139
        if ( !$borrower_number ) { #parameters not valid
148
        if ( !$borrower_number ) {    #parameters not valid
140
            $errLinkNotValid = 1;
149
            $errLinkNotValid = 1;
141
        }
150
        }
142
        elsif ( $password ne $repeatPassword ) { #passwords does not match
151
        elsif ( $password ne $repeatPassword ) {    #passwords does not match
143
            $errPassNotMatch = 1;
152
            $errPassNotMatch = 1;
144
        }
153
        }
145
        elsif ( length($password) < $minPassLength ) { #password too short
154
        elsif ( length($password) < $minPassLength ) {    #password too short
146
            $errPassTooShort = 1;
155
            $errPassTooShort = 1;
147
        }
156
        }
148
        $template->param(
157
        $template->param(
Lines 157-164 elsif ( $query->param('passwordReset') ) { Link Here
157
        );
166
        );
158
    }
167
    }
159
}
168
}
160
elsif ($uniqueKey) {  #reset password form
169
elsif ($uniqueKey) {    #reset password form
161
    #check if the link is valid
170
                        #check if the link is valid
162
    ( $borrower_number, $username ) = GetValidLinkInfo($uniqueKey);
171
    ( $borrower_number, $username ) = GetValidLinkInfo($uniqueKey);
163
172
164
    if ( !$borrower_number ) {
173
    if ( !$borrower_number ) {
Lines 171-180 elsif ($uniqueKey) { #reset password form Link Here
171
        email           => $email,
180
        email           => $email,
172
        uniqueKey       => $uniqueKey,
181
        uniqueKey       => $uniqueKey,
173
        username        => $username,
182
        username        => $username,
174
        errLinkNotValid => $errLinkNotValid
183
        errLinkNotValid => $errLinkNotValid,
184
        hasError        => ( $errLinkNotValid ? 1 : 0 ),
175
    );
185
    );
176
}
186
}
177
else { #password recovery form (to send email)
187
else {    #password recovery form (to send email)
178
    $template->param( password_recovery => 1 );
188
    $template->param( password_recovery => 1 );
179
}
189
}
180
190
(-)a/t/db_dependent/Passwordrecovery.t (-1 / +157 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use C4::Context;
21
use C4::Letters;
22
use Koha::Database;
23
use Koha::Borrowers;
24
25
use Test::More tests => 16;
26
27
use_ok('C4::Passwordrecovery');
28
29
my $schema = Koha::Database->new()->schema();
30
$schema->storage->txn_begin();
31
32
my $dbh = C4::Context->dbh;
33
$dbh->{RaiseError} = 1;
34
35
#
36
# Start with fresh data
37
#
38
39
my $borrowernumber1 = '2000000000';
40
my $borrowernumber2 = '2000000001';
41
my $userid1 = "I83MFItzRpGPxD3vW0";
42
my $userid2 = "Gh5t43980hfSAOcvne";
43
my $email1  = $userid1 . '@koha-community.org';
44
my $email2  = $userid2 . '@koha-community.org';
45
my $uuid1   = "ABCD1234";
46
my $uuid2   = "WXYZ0987";
47
48
my $categorycode = 'S'; #  staff
49
my $branch       = $schema->resultset('Branch')->first(); #  legit branch from your db
50
51
$schema->resultset('BorrowerPasswordRecovery')->delete_all();
52
53
$schema->resultset('Borrower')->create(
54
    {
55
        borrowernumber  => $borrowernumber1,
56
        surname         => '',
57
        address         => '',
58
        city            => '',
59
        userid          => $userid1,
60
        email           => $email1,
61
        categorycode    => $categorycode,
62
        branchcode      => $branch,
63
    }
64
);
65
$schema->resultset('Borrower')->create(
66
    {
67
        borrowernumber  => $borrowernumber2,
68
        surname         => '',
69
        address         => '',
70
        city            => '',
71
        userid          => $userid2,
72
        email           => $email2,
73
        categorycode    => $categorycode,
74
        branchcode      => $branch,
75
    }
76
);
77
78
$schema->resultset('BorrowerPasswordRecovery')->create(
79
    {
80
        borrowernumber => $borrowernumber1,
81
        uuid           => $uuid1,
82
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->add( days => 2 )->datetime()
83
    }
84
);
85
$schema->resultset('BorrowerPasswordRecovery')->create(
86
    {
87
        borrowernumber => $borrowernumber2,
88
        uuid           => $uuid2,
89
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 2 )->datetime()
90
    }
91
);
92
93
can_ok( "C4::Passwordrecovery", qw(ValidateBorrowernumber GetValidLinkInfo SendPasswordRecoveryEmail CompletePasswordRecovery) );
94
95
################################################
96
# C4::Passwordrecovery::ValidateBorrowernumber #
97
################################################
98
99
ok(   C4::Passwordrecovery::ValidateBorrowernumber($borrowernumber1), "[ValidateBorrowernumber] Borrower has a password recovery entry" );
100
ok( ! C4::Passwordrecovery::ValidateBorrowernumber($borrowernumber2), "[ValidateBorrowernumber] Borrower's number is not found; password recovery entry is expired" );
101
ok( ! C4::Passwordrecovery::ValidateBorrowernumber(9999), "[ValidateBorrowernumber] Borrower has no password recovery entry" );
102
103
##########################################
104
# C4::Passwordrecovery::GetValidLinkInfo #
105
##########################################
106
107
my ($bnum1, $uname1) = C4::Passwordrecovery::GetValidLinkInfo($uuid1);
108
my ($bnum2, $uname2) = C4::Passwordrecovery::GetValidLinkInfo($uuid2);
109
my ($bnum3, $uname3) = C4::Passwordrecovery::GetValidLinkInfo("THISISANINVALIDUUID");
110
111
is( $bnum1, $borrowernumber1, "[GetValidLinkInfo] Borrower has a valid link" );
112
is( $uname1, $userid1, "[GetValidLinkInfo] Borrower's username is fetched when a valid link is found" );
113
ok( ! defined($bnum2), "[GetValidLinkInfo] Borrower's link is no longer valid; entry is expired" );
114
ok( ! defined($bnum3), "[GetValidLinkInfo] Invalid UUID returns no borrowernumber" );
115
116
##################################################
117
# C4::Passwordrecovery::CompletePasswordRecovery #
118
##################################################
119
120
ok( C4::Passwordrecovery::CompletePasswordRecovery($uuid1) == 2, "[CompletePasswordRecovery] Completing a password recovery deletes the entry and expired entries" );
121
122
$schema->resultset('BorrowerPasswordRecovery')->create(
123
    {
124
        borrowernumber => $borrowernumber2,
125
        uuid           => $uuid2,
126
        valid_until    => DateTime->now( time_zone => C4::Context->tz() )->subtract( days => 2 )->datetime()
127
    }
128
);
129
130
ok( C4::Passwordrecovery::CompletePasswordRecovery($uuid2) == 1, "[CompletePasswordRecovery] An expired or invalid UUID purges expired entries" );
131
ok( C4::Passwordrecovery::CompletePasswordRecovery($uuid2) == 0, "[CompletePasswordRecovery] Returns 0 on a clean table" );
132
133
###################################################
134
# C4::Passwordrecovery::SendPasswordRecoveryEmail #
135
###################################################
136
137
my $borrower = shift [ Koha::Borrowers->search( { userid => $userid1 } ) ];
138
ok( C4::Passwordrecovery::SendPasswordRecoveryEmail($borrower, $email1, 0) == 1, "[SendPasswordRecoveryEmail] Returns 1 on success" );
139
my $letters = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber1, limit => 99 } );
140
ok( scalar @$letters == 1, "[SendPasswordRecoveryEmail] There is a letter in the queue for our borrower");
141
142
my $bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } );
143
my $tempuuid1 = $bpr->next->uuid;
144
145
C4::Passwordrecovery::SendPasswordRecoveryEmail($borrower, $email1, 1);
146
147
$bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } );
148
my $tempuuid2 = $bpr->next->uuid;
149
150
$letters = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber1, limit => 99 } );
151
152
ok( $tempuuid1 ne $tempuuid2, "[SendPasswordRecoveryEmail] UPDATE == ON changes uuid in the database and updates the expirydate");
153
ok( scalar @$letters == 2, "[SendPasswordRecoveryEmail] UPDATE == ON sends a new letter with updated uuid");
154
155
$schema->storage->txn_rollback();
156
157
1;

Return to bug 8753