don't send when password is supplied, RT#34705
[freeside.git] / FS / FS / contact.pm
index 589fc7c..38b7fd7 100644 (file)
@@ -259,7 +259,10 @@ sub insert {
   }
 
   if (      $link_hash{'selfservice_access'} eq 'R'
-       or ( $link_hash{'selfservice_access'} && $cust_contact )
+       or ( $link_hash{'selfservice_access'}
+            && $cust_contact
+            && ! length($self->_password)
+          )
      )
   {
     my $error = $self->send_reset_email( queue=>1 );
@@ -452,8 +455,11 @@ sub replace {
              );
     my $contact_phone = qsearchs('contact_phone', \%cp);
 
+    my $pv = $self->get($pf);
+       $pv =~ s/\s//g;
+
     #if new value is empty, delete old entry
-    if (!$self->get($pf)) {
+    if (!$pv) {
       if ($contact_phone) {
         $error = $contact_phone->delete;
         if ( $error ) {
@@ -466,7 +472,7 @@ sub replace {
 
     $contact_phone ||= new FS::contact_phone \%cp;
 
-    my %cpd = _parse_phonestring( $self->get($pf) );
+    my %cpd = _parse_phonestring( $pv );
     $contact_phone->set( $_ => $cpd{$_} ) foreach keys %cpd;
 
     my $method = $contact_phone->contactphonenum ? 'replace' : 'insert';