summaryrefslogtreecommitdiff
path: root/FS/FS/ClientAPI/MyAccount.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/ClientAPI/MyAccount.pm')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm28
1 files changed, 13 insertions, 15 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 421a082..81da5bc 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -24,6 +24,7 @@ FS::ClientAPI->register_handlers(
'MyAccount/list_pkgs' => \&list_pkgs,
'MyAccount/order_pkg' => \&order_pkg,
'MyAccount/cancel_pkg' => \&cancel_pkg,
+ 'MyAccount/charge' => \&charge,
);
use vars qw( @cust_main_editable_fields );
@@ -35,26 +36,23 @@ use vars qw( @cust_main_editable_fields );
);
#store in db?
-my $cache = new Cache::SharedMemoryCache();
+my $cache = new Cache::SharedMemoryCache( {
+ 'namespace' => 'FS::ClientAPI::MyAccount',
+} );
-#false laziness w/FS::ClientAPI::passwd::passwd (needs to handle encrypted pw)
+#false laziness w/FS::ClientAPI::passwd::passwd
sub login {
my $p = shift;
my $svc_domain = qsearchs('svc_domain', { 'domain' => $p->{'domain'} } )
- or return { error => "Domain not found" };
+ or return { error => 'Domain '. $p->{'domain'}. ' not found' };
- my $svc_acct =
- ( length($p->{'password'}) < 13
- && qsearchs( 'svc_acct', { 'username' => $p->{'username'},
- 'domsvc' => $svc_domain->svcnum,
- '_password' => $p->{'password'} } )
- )
- || qsearchs( 'svc_acct', { 'username' => $p->{'username'},
- 'domsvc' => $svc_domain->svcnum,
- '_password' => $p->{'password'} } );
-
- unless ( $svc_acct ) { return { error => 'Incorrect password.' } }
+ my $svc_acct = qsearchs( 'svc_acct', { 'username' => $p->{'username'},
+ 'domsvc' => $svc_domain->svcnum, }
+ );
+ return { error => 'User not found.' } unless $svc_acct;
+ return { error => 'Incorrect password.' }
+ unless $svc_acct->check_password($p->{'password'});
my $session = {
'svcnum' => $svc_acct->svcnum,
@@ -277,7 +275,7 @@ sub order_pkg {
$cust_pkg->reexport;
}
- return { error => '' };
+ return { error => '', pkgnum => $cust_pkg->pkgnum };
}