Bugzilla – Attachment 45226 Details for
Bug 8753
Add forgot password link to OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8753 - Use Koha::Borrowers instead of C4::Members
Bug-8753---Use-KohaBorrowers-instead-of-C4Members.patch (text/plain), 6.13 KB, created by
Charles Farmer
on 2015-11-30 14:27:16 UTC
(
hide
)
Description:
Bug 8753 - Use Koha::Borrowers instead of C4::Members
Filename:
MIME Type:
Creator:
Charles Farmer
Created:
2015-11-30 14:27:16 UTC
Size:
6.13 KB
patch
obsolete
>From af7fe5e3f9347cc3f6fedb23b6d712c4657f6aa9 Mon Sep 17 00:00:00 2001 >From: mxbeaulieu <maxime.beaulieu@inlibro.com> >Date: Fri, 24 Jul 2015 16:16:03 -0400 >Subject: [PATCH] Bug 8753 - Use Koha::Borrowers instead of C4::Members >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Use the new library to search for borrowers. >Changed how the $borrower variable is used since it is now a Koha::Borrower object. > >Removed the $protocol parameter from the generated link. It should be included in the OPACBaseURL syspref. > > modified: C4/Passwordrecovery.pm > modified: opac/opac-password-recovery.pl > >Signed-off-by: Marc Véron <veron@veron.ch> >--- > C4/Passwordrecovery.pm | 15 +++++++-------- > opac/opac-password-recovery.pl | 16 ++++++++-------- > 2 files changed, 15 insertions(+), 16 deletions(-) > >diff --git a/C4/Passwordrecovery.pm b/C4/Passwordrecovery.pm >index 67b5695..f90d27c 100644 >--- a/C4/Passwordrecovery.pm >+++ b/C4/Passwordrecovery.pm >@@ -102,9 +102,8 @@ sub GetValidLinkInfo { > =cut > > sub SendPasswordRecoveryEmail { >- my $borrower = shift; # from GetMember >+ my $borrower = shift; # Koha::Borrower > my $userEmail = shift; #to_address (the one specified in the request) >- my $protocol = shift; #only required to determine if 'http' or 'https' > my $update = shift; > > my $schema = Koha::Database->new->schema; >@@ -119,26 +118,26 @@ sub SendPasswordRecoveryEmail { > if($update){ > my $rs = $schema->resultset('BorrowerPasswordRecovery')->search( > { >- borrowernumber => $borrower->{'borrowernumber'}, >+ borrowernumber => $borrower->borrowernumber, > }); > $rs->update({uuid => $uuid_str, valid_until => $expirydate->datetime()}); > } else { > my $rs = $schema->resultset('BorrowerPasswordRecovery')->create({ >- borrowernumber=>$borrower->{'borrowernumber'}, >+ borrowernumber=>$borrower->borrowernumber, > uuid => $uuid_str, > valid_until=> $expirydate->datetime() > }); > } > > # create link >- my $uuidLink = $protocol . C4::Context->preference( 'OPACBaseURL' ) . "/cgi-bin/koha/opac-password-recovery.pl?uniqueKey=$uuid_str"; >+ my $uuidLink = C4::Context->preference( 'OPACBaseURL' ) . "/cgi-bin/koha/opac-password-recovery.pl?uniqueKey=$uuid_str"; > > # prepare the email > my $letter = C4::Letters::GetPreparedLetter ( > module => 'members', > letter_code => 'PASSWORD_RESET', >- branchcode => $borrower->{branchcode}, >- substitute => {passwordreseturl => $uuidLink, user => $borrower->{userid} }, >+ branchcode => $borrower->branchcode, >+ substitute => {passwordreseturl => $uuidLink, user => $borrower->userid }, > ); > > # define to/from emails >@@ -146,7 +145,7 @@ sub SendPasswordRecoveryEmail { > > C4::Letters::EnqueueLetter( { > letter => $letter, >- borrowernumber => $borrower->{borrowernumber}, >+ borrowernumber => $borrower->borrowernumber, > to_address => $userEmail, > from_address => $kohaEmail, > message_transport_type => 'email', >diff --git a/opac/opac-password-recovery.pl b/opac/opac-password-recovery.pl >index e2cd74e..ba7bcb6 100755 >--- a/opac/opac-password-recovery.pl >+++ b/opac/opac-password-recovery.pl >@@ -6,11 +6,12 @@ use CGI; > > use C4::Auth; > use C4::Koha; >-use C4::Members qw(changepassword Search); >+use C4::Members qw(changepassword); > use C4::Output; > use C4::Context; > use C4::Passwordrecovery qw(SendPasswordRecoveryEmail ValidateBorrowernumber GetValidLinkInfo CompletePasswordRecovery); > use Koha::AuthUtils qw(hash_password); >+use Koha::Borrowers; > my $query = new CGI; > use HTML::Entities; > >@@ -49,17 +50,16 @@ my $errPassNotMatch; > my $errPassTooShort; > > if ( $query->param('sendEmail') || $query->param('resendEmail') ) { >- my $protocol = $query->https() ? "https://" : "http://"; > #try with the main email > $email ||= ''; # avoid undef > my $borrower; > my $search_results; > # Find the borrower by his userid or email > if( $username ){ >- $search_results = Search({ userid => $username }); >+ $search_results = [ Koha::Borrowers->search({ userid => $username }) ]; > } > elsif ( $email ){ >- $search_results = Search({ '' => $email }, undef, undef, undef, ['emailpro', 'email', 'B_email']); >+ $search_results = [ Koha::Borrowers->search({-or => {email => $email, emailpro=> $email, B_email=>$email }}) ]; > } > if ( not $search_results ){ > $hasError = 1; >@@ -70,8 +70,8 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) { > $errTooManyEmailFound = 1; > } > elsif( $borrower = shift @$search_results ){ # One matching borrower >- $username ||= $borrower->{'userid'}; >- my @emails = ( $borrower->{'email'}, $borrower->{'emailpro'}, $borrower->{'B_email'} ); >+ $username ||= $borrower->userid; >+ my @emails = ( $borrower->email, $borrower->emailpro, $borrower->B_email ); > # Is the given email one of the borrower's ? > if( $email && !($email ~~ @emails) ){ > $hasError = 1; >@@ -86,7 +86,7 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) { > $errNoBorrowerEmail = 1; > } > # Check if a password reset already issued for this borrower AND we are not asking for a new email >- elsif( ValidateBorrowernumber( $borrower->{'borrowernumber'} ) && !$query->param('resendEmail') ){ >+ elsif( ValidateBorrowernumber( $borrower->borrowernumber ) && !$query->param('resendEmail') ){ > $hasError = 1; > $errAlreadyStartRecovery = 1; > } >@@ -108,7 +108,7 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) { > username => $username > ); > } >- elsif ( SendPasswordRecoveryEmail( $borrower, $email, $protocol, $query->param('resendEmail') ) ) {#generate uuid and send recovery email >+ elsif ( SendPasswordRecoveryEmail( $borrower, $email, $query->param('resendEmail') ) ) {#generate uuid and send recovery email > $template->param( > mail_sent => 1, > email => $email >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8753
:
21502
|
21512
|
21521
|
21849
|
22175
|
22430
|
24586
|
24780
|
24781
|
24846
|
24853
|
24854
|
24855
|
24862
|
24906
|
24907
|
24908
|
25038
|
25039
|
25051
|
29111
|
33175
|
33176
|
34472
|
36819
|
37492
|
39049
|
39144
|
39165
|
39166
|
39167
|
39168
|
39827
|
41181
|
41192
|
41193
|
41455
|
41686
|
41687
|
41688
|
41706
|
43017
|
43183
|
43576
|
44305
|
44306
|
44307
|
44308
|
44309
|
44310
|
44311
|
44323
|
44324
|
44325
|
44326
|
44327
|
44329
|
44330
|
45209
|
45210
|
45211
|
45212
|
45213
|
45214
|
45215
|
45223
|
45224
|
45225
|
45226
|
45227
|
45228
|
45229
|
45230
|
46379
|
47164
|
47165
|
47166
|
47167
|
47168
|
47169
|
47170
|
47171
|
47357
|
47366