summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorlevinse <levinse>2010-12-15 15:09:49 +0000
committerlevinse <levinse>2010-12-15 15:09:49 +0000
commitf73dba57a29dea6dc340f61592ea32e081a74a1f (patch)
tree5a76394f80c269cef8b5219dd684a66bbfda4f9a /FS
parent71dc0697c42525fc94cedda770bef901da14baa7 (diff)
self-service improvements, RT10883
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm44
-rw-r--r--FS/FS/Conf.pm15
2 files changed, 57 insertions, 2 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index a46e7eccd..21a923f33 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,
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 35d75a2ce..25b6a08bc 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2270,6 +2270,21 @@ and customer address. Include units.',
},
{
+ 'key' => 'selfservice_server-login_svcpart',
+ 'section' => 'self-service',
+ 'description' => 'If specified, only allow the specified svcparts to login to self-service.',
+ 'type' => 'select-part_svc',
+ 'multiple' => 1,
+ },
+
+ {
+ 'key' => 'selfservice_server-view-wholesale',
+ 'section' => 'self-service',
+ 'description' => 'If enabled, use a wholesale package view in the self-service.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'selfservice-agent_signup',
'section' => 'self-service',
'description' => 'Allow agent signup via self-service.',