[freeside-commits] freeside/FS/FS/ClientAPI MyAccount.pm, 1.73, 1.74
Ivan,,,
ivan at wavetail.420.am
Tue Sep 9 14:29:45 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv3543
Modified Files:
MyAccount.pm
Log Message:
this should allow implied primary services to log into selfservice when selfservice_server-primary_only is on
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- MyAccount.pm 2 Sep 2008 15:37:07 -0000 1.73
+++ MyAccount.pm 9 Sep 2008 21:29:41 -0000 1.74
@@ -1,8 +1,9 @@
package FS::ClientAPI::MyAccount;
use strict;
-use vars qw($cache);
-use subs qw(_cache);
+use vars qw( $cache $DEBUG );
+use subs qw( _cache _provision );
+use Data::Dumper;
use Digest::MD5 qw(md5_hex);
use Date::Format;
use Business::CreditCard;
@@ -28,6 +29,8 @@
use FS::acct_rt_transaction;
use HTML::Entities;
+$DEBUG = 0;
+
#false laziness with FS::cust_main
BEGIN {
eval "use Time::Local;";
@@ -46,8 +49,6 @@
ss paytype paystate stateid stateid_state
);
-use subs qw(_provision);
-
sub _cache {
$cache ||= new FS::ClientAPI_SessionCache( {
'namespace' => 'FS::ClientAPI::MyAccount',
@@ -88,11 +89,15 @@
);
return { error => 'User not found.' } unless $svc_acct;
- my $pkg_svc = $svc_acct->cust_svc->pkg_svc;
+ #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_svc ne 'Y' );
+ my $cust_svc = $svc_acct->cust_svc;
return { error => 'Only primary user may log in.' }
if $conf->exists('selfservice_server-primary_only')
- && ( ! $pkg_svc || $pkg_svc->primary_svc ne 'Y' );
-
+ && $cust_svc->svcpart != $cust_svc->cust_pkg->svcpart('svc_acct');
+
return { error => 'Incorrect password.' }
unless $svc_acct->check_password($p->{'password'});
@@ -1099,6 +1104,8 @@
sub provision_acct {
my $p = shift;
+ warn "provision_acct called\n"
+ if $DEBUG;
return { 'error' => gettext('passwords_dont_match') }
if $p->{'_password'} ne $p->{'_password2'};
@@ -1112,6 +1119,8 @@
unless ($domains{$p->{'domsvc'}});
}
+ warn "provision_acct calling _provision\n"
+ if $DEBUG;
_provision( 'FS::svc_acct',
[qw(username _password domsvc)],
[qw(username _password domsvc)],
@@ -1133,6 +1142,8 @@
sub _provision {
my( $class, $fields, $return_fields, $p ) = splice(@_, 0, 4);
+ warn "_provision called for $class\n"
+ if $DEBUG;
my($context, $session, $custnum) = _custoragent_session_custnum($p);
return { 'error' => $session } if $context eq 'error';
@@ -1144,27 +1155,42 @@
my $pkgnum = $p->{'pkgnum'};
+ warn "searching for custnum $custnum pkgnum $pkgnum\n"
+ if $DEBUG;
my $cust_pkg = qsearchs('cust_pkg', { 'custnum' => $custnum,
'pkgnum' => $pkgnum,
} )
or return { 'error' => "unknown pkgnum $pkgnum" };
+ warn "searching for svcpart ". $p->{'svcpart'}. "\n"
+ if $DEBUG;
my $part_svc = qsearchs('part_svc', { 'svcpart' => $p->{'svcpart'} } )
or return { 'error' => "unknown svcpart $p->{'svcpart'}" };
+ warn "creating $class record\n"
+ if $DEBUG;
my $svc_x = $class->new( {
'pkgnum' => $p->{'pkgnum'},
'svcpart' => $p->{'svcpart'},
map { $_ => $p->{$_} } @$fields
} );
+ warn "inserting $class record\n"
+ if $DEBUG;
my $error = $svc_x->insert;
- $svc_x = qsearchs($svc_x->table, { 'svcnum' => $svc_x->svcnum })
- unless $error;
- return { 'svc' => $part_svc->svc,
- 'error' => $error,
- map { $_ => $svc_x->get($_) } @$return_fields
- };
+ unless ( $error ) {
+ warn "finding inserted record for svcnum ". $svc_x->svcnum. "\n"
+ if $DEBUG;
+ $svc_x = qsearchs($svc_x->table, { 'svcnum' => $svc_x->svcnum })
+ }
+
+ my $return = { 'svc' => $part_svc->svc,
+ 'error' => $error,
+ map { $_ => $svc_x->get($_) } @$return_fields
+ };
+ warn "_provision returning ". Dumper($return). "\n"
+ if $DEBUG;
+ return $return;
}
More information about the freeside-commits
mailing list