X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=181c994c4d20da4acfb11c954c67a8c1e8016127;hb=aaace663fe7ff34479a707f3976c32010e4a1845;hp=3fc51b37ee9604ebdc39a2ee5a3828e475ec717b;hpb=123bc067cc9fd8b247fb0b4e9a86066f32e83991;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 3fc51b37e..181c994c4 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -171,6 +171,13 @@ sub login { ); return { error => 'User not found.' } unless $svc_acct; + if($conf->exists('selfservice_server-login_svcpart')) { + my @svcpart = $conf->config('selfservice_server-login_svcpart'); + my $svcpart = $svc_acct->cust_svc->svcpart; + return { error => 'Invalid user.' } + unless grep($_ eq $svcpart, @svcpart); + } + return { error => 'Incorrect password.' } unless $svc_acct->check_password($p->{'password'}); @@ -915,9 +922,42 @@ sub list_pkgs { my $cust_main = qsearchs('cust_main', $search ) or return { 'error' => "unknown custnum $custnum" }; - #return { 'cust_pkg' => [ map { $_->hashref } $cust_main->ncancelled_pkgs ] }; - my $conf = new FS::Conf; + +# the duplication below is necessary: +# 1. to maintain the current buggy behaviour wrt the cust_pkg and part_pkg +# hashes overwriting each other (setup and no_auto fields). Fixing that is a +# non-backwards-compatible change breaking the software of anyone using the API +# instead of the stock selfservice +# 2. to return cancelled packages as well - for wholesale and non-wholesale + if( $conf->exists('selfservice_server-view-wholesale') ) { + return { 'svcnum' => $session->{'svcnum'}, + 'custnum' => $custnum, + 'cust_pkg' => [ map { + { $_->hash, + part_pkg => [ map $_->hashref, $_->part_pkg ], + part_svc => + [ map $_->hashref, $_->available_part_svc ], + cust_svc => + [ map { my $ref = { $_->hash, + label => [ $_->label ], + }; + $ref->{_password} = $_->svc_x->_password + if $context eq 'agent' + && $conf->exists('agent-showpasswords') + && $_->part_svc->svcdb eq 'svc_acct'; + $ref; + } $_->cust_svc + ], + }; + } $cust_main->cust_pkg + ], + 'small_custview' => + small_custview( $cust_main, $conf->config('countrydefault') ), + 'wholesale_view' => 1, + 'date_format' => $conf->config('date_format') || '%m/%d/%Y', + }; + } { 'svcnum' => $session->{'svcnum'}, 'custnum' => $custnum,