X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcontact.pm;h=761f751cde871998f85478041a9a9e0361b9c321;hb=4f53fbbb88637f3c7d44db2e16933d1754323b78;hp=4db3cdfd1f49aff287147569d9c7eb5b8ff2a815;hpb=b11b95320dcb860212129de464d6349e4ac6da5e;p=freeside.git diff --git a/FS/FS/contact.pm b/FS/FS/contact.pm index 4db3cdfd1..761f751cd 100644 --- a/FS/FS/contact.pm +++ b/FS/FS/contact.pm @@ -131,7 +131,6 @@ sub insert { my $dbh = dbh; my $error = $self->SUPER::insert; - $error ||= $self->insert_password_history; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -191,6 +190,15 @@ sub insert { } } + if ( $self->get('password') ) { + my $error = $self->is_password_allowed($self->get('password')) + || $self->change_password($self->get('password')); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; @@ -578,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', @@ -614,7 +648,7 @@ sub authenticate_password { $hash eq $check_hash; - } else { + } else { return 0 if $self->_password eq '';