diff options
| author | Christopher Burger <burgerc@freeside.biz> | 2019-05-07 09:19:57 -0400 | 
|---|---|---|
| committer | Christopher Burger <burgerc@freeside.biz> | 2019-05-07 15:12:42 -0400 | 
| commit | 4f53fbbb88637f3c7d44db2e16933d1754323b78 (patch) | |
| tree | 736d8b4ee7e7510c03aa4ccdcb6bd110111e3df4 /FS | |
| parent | 9e552ab0b3cffa9fd345320d77f9f8751766a5a6 (diff) | |
RT# 82132 - updated selfservice login to use config username-uppercase
Conflicts:
	FS/FS/ClientAPI/MyAccount.pm
	FS/FS/contact.pm
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 11 | ||||
| -rw-r--r-- | FS/FS/contact.pm | 28 | 
2 files changed, 36 insertions, 3 deletions
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',  | 
