option to only allow primary users access to the self-service server
authorivan <ivan>
Mon, 21 Jun 2004 10:26:14 +0000 (10:26 +0000)
committerivan <ivan>
Mon, 21 Jun 2004 10:26:14 +0000 (10:26 +0000)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/Conf.pm
FS/FS/cust_svc.pm

index 271d0c2..f2cd488 100644 (file)
@@ -60,6 +60,8 @@ sub login {
                                          'domsvc'    => $svc_domain->svcnum, }
                          );
   return { error => 'User not found.' } unless $svc_acct;
                                          'domsvc'    => $svc_domain->svcnum, }
                          );
   return { error => 'User not found.' } unless $svc_acct;
+
+
   return { error => 'Incorrect password.' }
     unless $svc_acct->check_password($p->{'password'});
 
   return { error => 'Incorrect password.' }
     unless $svc_acct->check_password($p->{'password'});
 
@@ -73,6 +75,12 @@ sub login {
     $session->{'custnum'} = $cust_main->custnum;
   }
 
     $session->{'custnum'} = $cust_main->custnum;
   }
 
+  my $conf = new FS::Conf;
+  my $pkg_svc = $svc_acct->cust_svc->pkg_svc;
+  return { error => 'Only primary user may log in.' } 
+    if $conf->exists('selfservice_server-primary_only')
+       && ( ! $pkg_svc || $pkg_svc->primary ne 'Y' );
+
   my $session_id;
   do {
     $session_id = md5_hex(md5_hex(time(). {}. rand(). $$))
   my $session_id;
   do {
     $session_id = md5_hex(md5_hex(time(). {}. rand(). $$))
index 3cb5f14..6f7b2d6 100644 (file)
@@ -1248,6 +1248,15 @@ httemplate/docs/config.html
     'type'        => 'textarea',
   },
 
     'type'        => 'textarea',
   },
 
+  {
+    'key'         => 'selfservice_server-primary_only',
+    'section'     => '',
+    'description' => 'Only allow primary accounts to access self-service functionality.',
+    'type'        => 'checkbox',
+  },
+
+
+
 );
 
 1;
 );
 
 1;
index b975396..fae265d 100644 (file)
@@ -590,6 +590,23 @@ sub get_session_history {
 
 }
 
 
 }
 
+=item pkg_svc
+
+Returns the pkg_svc record for for this service, if applicable.
+
+=cut
+
+sub pkg_svc {
+  my $self = shift;
+  my $cust_pkg = $self->cust_pkg;
+  return undef unless $cust_pkg;
+
+  qsearchs( 'pkg_svc', { 'svcpart' => $self->svcpart,
+                         'pkgpart' => $cust_pkg->pkgpart,
+                       }
+          );
+}
+
 =back
 
 =head1 BUGS
 =back
 
 =head1 BUGS