Bugzilla – Attachment 56993 Details for
Bug 17494
Koha generating duplicate self registration tokens
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17494 - Prevent duplicate tokens from getting stored
Bug-17494---Prevent-duplicate-tokens-from-getting-.patch (text/plain), 2.53 KB, created by
Kyle M Hall (khall)
on 2016-10-31 11:17:25 UTC
(
hide
)
Description:
Bug 17494 - Prevent duplicate tokens from getting stored
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-10-31 11:17:25 UTC
Size:
2.53 KB
patch
obsolete
>From 8b894ef585a5ec04179484d087c4bec96836f710 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 31 Oct 2016 11:15:02 +0000 >Subject: [PATCH] Bug 17494 - Prevent duplicate tokens from getting stored > >--- > Koha/Exceptions/Patron/Modification.pm | 12 ++++++++++++ > Koha/Patron/Modification.pm | 19 +++++++++++++++++++ > opac/opac-memberentry.pl | 3 +++ > 3 files changed, 34 insertions(+) > create mode 100644 Koha/Exceptions/Patron/Modification.pm > >diff --git a/Koha/Exceptions/Patron/Modification.pm b/Koha/Exceptions/Patron/Modification.pm >new file mode 100644 >index 0000000..1068fbb >--- /dev/null >+++ b/Koha/Exceptions/Patron/Modification.pm >@@ -0,0 +1,12 @@ >+package Koha::Exceptions::Patron::Modification; >+ >+use Modern::Perl; >+ >+use Exception::Class ( >+ 'Koha::Exceptions::Koha::Patron::Modification::DuplicateVerificationToken' => { >+ isa => 'Koha::Exceptions::Object', >+ description => "The verification token given already exists", >+ }, >+); >+ >+1; >diff --git a/Koha/Patron/Modification.pm b/Koha/Patron/Modification.pm >index 5407172..63f124f 100644 >--- a/Koha/Patron/Modification.pm >+++ b/Koha/Patron/Modification.pm >@@ -23,6 +23,9 @@ use Carp; > > use Koha::Database; > >+use Koha::Patron::Modifications; >+use Koha::Exceptions::Patron::Modification; >+ > use base qw(Koha::Object); > > =head1 NAME >@@ -33,6 +36,22 @@ Koha::Patron::Modification - Class represents a request to modify or create a pa > > =cut > >+=head2 store >+ >+=cut >+ >+sub store { >+ my ($self) = @_; >+ >+ if ( $self->verification_token ) { >+ if ( Koha::Patron::Modifications->search( { verification_token => $self->verification_token } )->count() ) { >+ Koha::Exceptions::Koha::Patron::Modification::DuplicateVerificationToken->throw; >+ } >+ } >+ >+ return $self->SUPER::store(); >+} >+ > =head2 approve > > $m->approve(); >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 6bdd66a..e03d503 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -139,6 +139,9 @@ if ( $action eq 'create' ) { > $template->param( 'email' => $borrower{'email'} ); > > my $verification_token = md5_hex( time().{}.rand().{}.$$ ); >+ while ( Koha::Patron::Modifications->search( { verification_token => $verification_token } )->count() ) { >+ $verification_token = md5_hex( time().{}.rand().{}.$$ ); >+ } > > $borrower{password} = random_string(".........."); > $borrower{verification_token} = $verification_token; >-- >2.1.4
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 17494
:
56914
|
56992
|
56993
|
57008
|
57204
|
57205
|
57206
|
57212
|
57213
|
57214