diff options
Diffstat (limited to 'FS')
| -rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 79 | ||||
| -rw-r--r-- | FS/FS/ClientAPI_XMLRPC.pm | 2 | ||||
| -rw-r--r-- | FS/FS/Conf.pm | 10 | 
3 files changed, 91 insertions, 0 deletions
| diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index e3afac14a..76084394d 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -251,6 +251,25 @@ sub logout {    }  } +sub switch_acct { +  my $p = shift; + +  my($context, $session, $custnum) = _custoragent_session_custnum($p); +  return { 'error' => $session } if $context eq 'error'; + +  my $svc_acct = _customer_svc_x( $custnum, $p->{'svcnum'}, 'svc_acct' ) +    or return { 'error' => "Service not found" }; + +  $session->{'svcnum'} = $svc_acct->svcnum; + +  my $conf = new FS::Conf; +  my $timeout = $conf->config('selfservice-session_timeout') || '1 hour'; +  _cache->set( $p->{'session_id'}, $session, $timeout ); + +  return { 'error' => '' }; + +} +  sub payment_gateway {    # internal use only    # takes a cust_main and a cust_payby entry, returns the payment_gateway @@ -2260,6 +2279,66 @@ sub myaccount_passwd {  } +sub reset_passwd { +  my $p = shift; + +  my $conf = new FS::Conf; +  my $verification = $conf->config('selfservice-password_reset_verification') +    or return { 'error' => 'Password resets disabled' }; + +  my $username = $p->{'username'}; + +  my $svc_domain = qsearchs('svc_domain', { 'domain' => $p->{'domain'} } ) +    or return { 'error' => 'Account not found' }; + +  my $svc_acct = qsearchs('svc_acct', { 'username' => $p->{'username'}, +                                        'domsvc'   => $svc_domain->svcnum  } +                         ) +    or return { 'error' => 'Account not found' }; + +  my $cust_pkg = $svc_acct->cust_svc->cust_pkg +    or return { 'error' => 'Account not found' }; + +  my $cust_main = $cust_pkg->cust_main; + +  my %verify = ( +    'paymask' => sub {  +      my( $p, $cust_main ) = @_; +      $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/ +        && $p->{'paymask'} eq substr($cust_main->paymask, -4) +    }, +    'amount'  => sub { +      my( $p, $cust_main ) = @_; +      my $cust_pay = qsearchs({ +        'table' => 'cust_pay', +        'hashref' => { 'custnum' => $cust_main->custnum }, +        'order_by' => 'ORDER BY _date DESC LIMIT 1', +      }) +        or return 0; + +      $p->{'amount'} == $cust_pay->paid; +    }, +    'zip'     => sub { +      my( $p, $cust_main ) = @_; +      $p->{'zip'} eq $cust_main->zip +        || ( $cust_main->ship_zip && $p->{'zip'} eq $cust_main->ship_zip ); +    }, +  ); + +  foreach my $verify ( split(',', $verification) ) { + +    &{ $verify{$verify} }( $p, $cust_main ) +      or return { 'error' => 'Account not found' }; + +  } + +  #we're verified.  now what? +  + +  return { 'error' => '' }; +} + +  sub create_ticket {    my $p = shift;    my($context, $session, $custnum) = _custoragent_session_custnum($p); diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index 2913ffd47..b90951918 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -66,6 +66,7 @@ sub ss2clientapi {    'login_info'                => 'MyAccount/login_info',    'login'                     => 'MyAccount/login',    'logout'                    => 'MyAccount/logout', +  'switch_acct'               => 'MyAccount/switch_acct',    'customer_info'             => 'MyAccount/customer_info',    'customer_info_short'       => 'MyAccount/customer_info_short',    'edit_info'                 => 'MyAccount/edit_info',     #add to ss cgi! @@ -107,6 +108,7 @@ sub ss2clientapi {    'provision_external'        => 'MyAccount/provision_external',    'unprovision_svc'           => 'MyAccount/unprovision_svc',    'myaccount_passwd'          => 'MyAccount/myaccount_passwd', +  'reset_passwd'              => 'MyAccount/reset_passwd',    'create_ticket'             => 'MyAccount/create_ticket',    'get_ticket'                => 'MyAccount/get_ticket',    'adjust_ticket_priority'    => 'MyAccount/adjust_ticket_priority', diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 831b80fe5..e04ab1a31 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2465,6 +2465,16 @@ and customer address. Include units.',      'type'        => 'select-part_svc',      'multiple'    => 1,    }, + +  { +    'key'         => 'selfservice-password_reset_verification', +    'section'     => 'self-service', +    'description' => 'If enabled, specifies the type of verification required for self-service password resets.', +    'type'        => 'select', +    'select_hash' => [ '' => 'Password reset disabled', +                       'paymask,amount,zip' => 'Verify with credit card (or bank account) last 4 digits, payment amount and zip code', +                     ], +  },    {      'key'         => 'selfservice-recent-did-age', | 
