summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2004-06-21 10:26:14 +0000
committerivan <ivan>2004-06-21 10:26:14 +0000
commitedf90a3eb4219f72c8962ad86caacf409b896e8f (patch)
treebdae7210079e2ca81322c86c4beeb5beefd38230 /FS
parent4dbd0e09bd8fe1958eb294ebd425878c420afe6a (diff)
option to only allow primary users access to the self-service server
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm8
-rw-r--r--FS/FS/Conf.pm9
-rw-r--r--FS/FS/cust_svc.pm17
3 files changed, 34 insertions, 0 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 271d0c2cc..f2cd48863 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -60,6 +60,8 @@ sub login {
'domsvc' => $svc_domain->svcnum, }
);
return { error => 'User not found.' } unless $svc_acct;
+
+
return { error => 'Incorrect password.' }
unless $svc_acct->check_password($p->{'password'});
@@ -73,6 +75,12 @@ sub login {
$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(). $$))
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 3cb5f14a6..6f7b2d6d8 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1248,6 +1248,15 @@ httemplate/docs/config.html
'type' => 'textarea',
},
+ {
+ 'key' => 'selfservice_server-primary_only',
+ 'section' => '',
+ 'description' => 'Only allow primary accounts to access self-service functionality.',
+ 'type' => 'checkbox',
+ },
+
+
+
);
1;
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index b97539681..fae265d2e 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -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