Bugzilla – Attachment 108932 Details for
Bug 26067
Member email validation based on MX record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26067: Member email validation based on MX record.
0001-Bug-26067-Member-email-validation-based-on-MX-record.patch (text/plain), 8.04 KB, created by
Amit Gupta
on 2020-08-22 15:41:40 UTC
(
hide
)
Description:
Bug 26067: Member email validation based on MX record.
Filename:
MIME Type:
Creator:
Amit Gupta
Created:
2020-08-22 15:41:40 UTC
Size:
8.04 KB
patch
obsolete
>From fd7c346dd72034d1066be5c5ffea0e97ebc50893 Mon Sep 17 00:00:00 2001 >From: Amit Gupta <amit.gupta@informaticsglobal.com> >Date: Sat, 22 Aug 2020 15:38:20 +0000 >Subject: [PATCH] Bug 26067: Member email validation based on MX record. > >To Test >1. Enable system preference PatronSelfRegistration >2. Set PatronSelfRegistrationDefaultCategory for ex: ST >3. Set PatronSelfRegistrationLibraryList for ex: MPL >4. Open the page /cgi-bin/koha/opac-memberentry.pl >5. Fill the form and enter email address in Primary email, Secondary email and B_email for ex: > amit@gmail.c, amit1@gmail.c, amitgupta@gmail.c you will able to submit the page and it will not give any error message. >6. Apply the patch >7. Check system preference PatronEmailValidationMXrecord by default it show "Require". >8. Open the /cgi-bin/koha/opac-memberentry.pl again >9. Fill the form and enter email address in Primary email, Secondary email and B_email for ex: > amit@gmail.c, amit1@gmail.c, amitgupta@gmail.c and click on Submit button and it will give error message > "Invalid primary email address", "Invalid secondary email address", "Invalid email address". >10. This patch will check email, emailpro and B_email address field. >--- > ...tronEmailValidationMXrecord_add__system_preference.perl | 6 ++++++ > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/opac.pref | 6 ++++++ > .../opac-tmpl/bootstrap/en/modules/opac-memberentry.tt | 3 +++ > opac/opac-memberentry.pl | 14 ++++++++++++-- > 5 files changed, 28 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_26067_PatronEmailValidationMXrecord_add__system_preference.perl > >diff --git a/installer/data/mysql/atomicupdate/bug_26067_PatronEmailValidationMXrecord_add__system_preference.perl b/installer/data/mysql/atomicupdate/bug_26067_PatronEmailValidationMXrecord_add__system_preference.perl >new file mode 100644 >index 0000000..df0cc90 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_26067_PatronEmailValidationMXrecord_add__system_preference.perl >@@ -0,0 +1,6 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('PatronEmailValidationMXrecord','1','NULL','email address entered on patron self registration to pass Mail Exchange (MX) record check.','YesNo')" ); >+ >+ NewVersion( $DBversion, 26067, "Adds PatronEmailValidationMXrecord system preference"); >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 09564db..20f04cb 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -484,6 +484,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'), > ('PatronAutoComplete','1','Try|Don\'t try','to guess the patron being entered while typing a patron search for circulation or patron search. Only returns the first 10 results at a time.','YesNo'), > ('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free'), >+('PatronEmailValidationMXrecord','1','NULL','email address entered on patron self registration to pass Mail Exchange (MX) record check.','YesNo'), > ('patronimages','0',NULL,'Enable patron images for the Staff Client','YesNo'), > ('PatronRemovalDelay','',NULL,'Delay for removing anonymized patrons', 'Integer'), > ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index a9b9ff8..dcfd6e8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -783,6 +783,12 @@ OPAC: > > Self registration and modification: > - >+ - pref: PatronEmailValidationMXrecord >+ choices: >+ yes: Require >+ no: "Don't require" >+ - "email address entered on patron self registration to pass Mail Exchange (MX) record check." >+ - > - pref: PatronSelfRegistration > choices: > yes: Allow >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 0bf6bd1..08c4edc 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -78,8 +78,11 @@ > <ul> > [% FOREACH field IN invalid_form_fields %] > [% IF field == "email" %]<li>Contact information: <a href="#borrower_email">primary email address</a></li>[% END %] >+ [% IF field == "mxrecord_email" %]<li>Contact information: <a href="#borrower_email">Invalid primary email address</a></li>[% END %] > [% IF field == "emailpro" %]<li>Contact information: <a href="#borrower_emailpro">secondary email address</a></li>[% END %] >+ [% IF field == "mxrecord_emailpro" %]<li>Contact information: <a href="#borrower_emailpro">Invalid secondary email address</a></li>[% END %] > [% IF field == "B_email" %]<li>Alternate address information: <a href="#borrower_B_email">email address</a></li>[% END %] >+ [% IF field == "mxrecord_b_email" %]<li>Alternate address information: <a href="#borrower_B_email">Invalid email address</a></li>[% END %] > [% IF field == "password_match" %]<li>Passwords do not match! <a href="#password">password</a></li>[% END %] > [% IF field == "password_too_short" %] > <li>Password must be at least [% minPasswordLength | html %] characters long.</li> >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index a076cd3..7fa83a8 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -432,6 +432,8 @@ sub CheckForInvalidFields { > if ($borrower->{'email'}) { > unless ( Email::Valid->address($borrower->{'email'}) ) { > push(@invalidFields, "email"); >+ } elsif ( C4::Context->preference("PatronEmailValidationMXrecord") ) { >+ push(@invalidFields, "mxrecord_email") if ( !Email::Valid->address( -address => $borrower->{'email'}, -mxcheck => 1)); > } elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") ) { > my $patrons_with_same_email = Koha::Patrons->search( # FIXME Should be search_limited? > { >@@ -456,10 +458,18 @@ sub CheckForInvalidFields { > delete $borrower->{'repeat_email'}; > } > if ($borrower->{'emailpro'}) { >- push(@invalidFields, "emailpro") if (!Email::Valid->address($borrower->{'emailpro'})); >+ if ( C4::Context->preference("PatronEmailValidationMXrecord") ) { >+ push(@invalidFields, "mxrecord_emailpro") if (!Email::Valid->address( -address => $borrower->{'emailpro'}, -mxcheck => 1)); >+ } else { >+ push(@invalidFields, "emailpro") if (!Email::Valid->address($borrower->{'emailpro'})); >+ } > } > if ($borrower->{'B_email'}) { >- push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'})); >+ if ( C4::Context->preference("PatronEmailValidationMXrecord") ) { >+ push(@invalidFields, "mxrecord_b_email") if (!Email::Valid->address( -address => $borrower->{'B_email'}, -mxcheck => 1)); >+ } else { >+ push(@invalidFields, "B_email") if (!Email::Valid->address($borrower->{'B_email'})); >+ } > } > if ( defined $borrower->{'password'} > and $borrower->{'password'} ne $borrower->{'password2'} ) >-- >2.7.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 26067
:
107975
|
107978
|
107979
|
108660
| 108932