[freeside-commits] branch FREESIDE_3_BRANCH updated. 41baff41be27f0df19234232a0bffea69c323009

Christopher Burger burgerc at freeside.biz
Tue May 7 12:38:07 PDT 2019


The branch, FREESIDE_3_BRANCH has been updated
       via  41baff41be27f0df19234232a0bffea69c323009 (commit)
       via  4f53fbbb88637f3c7d44db2e16933d1754323b78 (commit)
      from  9e552ab0b3cffa9fd345320d77f9f8751766a5a6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 41baff41be27f0df19234232a0bffea69c323009
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue May 7 12:02:22 2019 -0400

    RT# 82132 - updated password reset by mail to use username-uppercase config
    
    Conflicts:
            FS/FS/ClientAPI/MyAccount.pm

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index dae2e1929..470d12b11 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -3130,7 +3130,11 @@ sub reset_passwd {
   my $cust_main = '';
   if ( $p->{'email'} ) { #new-style, changes contact and svc_acct
   
-    $contact = FS::contact->by_selfservice_email($p->{'email'});
+    $contact = FS::contact->by_selfservice_email($p->{'email'}, 'case_insensitive');
+
+    if ($conf->exists('username-uppercase') || $conf->exists('username-uppercase', $contact->cust_main->agentnum)) {
+      $contact = FS::contact->by_selfservice_email_custnum($p->{email}, $contact->custnum);
+    }
 
     $cust_main = $contact->cust_main if $contact;
 

commit 4f53fbbb88637f3c7d44db2e16933d1754323b78
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue May 7 09:19:57 2019 -0400

    RT# 82132 - updated selfservice login to use config username-uppercase
    
    Conflicts:
            FS/FS/ClientAPI/MyAccount.pm
            FS/FS/contact.pm

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index cb6a938da..dae2e1929 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -216,9 +216,9 @@ sub login {
   my $p = shift;
 
   my $conf = new FS::Conf;
-
   my $svc_x = '';
   my $session = {};
+
   if ( $p->{'domain'} eq 'svc_phone'
        && $conf->exists('selfservice_server-phone_login') ) { 
 
@@ -237,9 +237,16 @@ sub login {
     $svc_x = $svc_phone;
 
   } elsif ( $p->{email}
-              && (my $contact = FS::contact->by_selfservice_email($p->{email}))
+              && (my $contact = FS::contact->by_selfservice_email($p->{email},'case_insensitive'))
           )
   {
+    if ($conf->exists('username-uppercase') || $conf->exists('username-uppercase', $contact->cust_main->agentnum)) {
+      $contact = FS::contact->by_selfservice_email_custnum($p->{email}, $contact->custnum);
+    }
+
+    return { error => 'Email '.$p->{email}.' not found!'}
+      unless $contact;
+
     return { error => 'Incorrect contact password.' }
       unless $contact->authenticate_password($p->{'password'});
 
diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm
index 8f6b6a3b5..761f751cd 100644
--- a/FS/FS/contact.pm
+++ b/FS/FS/contact.pm
@@ -586,7 +586,33 @@ has that email address.
 =cut
 
 sub by_selfservice_email {
-  my($class, $email) = @_;
+  my($class, $email, $case_insensitive) = @_;
+
+  my $email_search = "emailaddress = '".$email."'";
+  $email_search = "LOWER(emailaddress) = LOWER('".$email."')" if $case_insensitive;
+
+  my $contact_email = qsearchs({
+    'table'     => 'contact_email',
+    'addl_from' => ' LEFT JOIN contact USING ( contactnum ) ',
+    'extra_sql' => " WHERE $email_search".
+                   " AND selfservice_access = 'Y' ".
+                   " AND ( disabled IS NULL OR disabled = '' )",
+  }) or return '';
+
+  $contact_email->contact;
+
+}
+
+=item by_selfservice_email_custnum EMAILADDRESS, CUSTNUM
+
+Alternate search constructor (class method).  Given an email address and custnum, returns
+the contact for that address and custnum. If that contact doesn't have selfservice access,
+or there isn't one, returns the empty string.
+
+=cut
+
+sub by_selfservice_email_custnum {
+  my($class, $email, $custnum) = @_;
 
   my $contact_email = qsearchs({
     'table'     => 'contact_email',

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm | 17 ++++++++++++++---
 FS/FS/contact.pm             | 28 +++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list