From: Ivan Kohler Date: Thu, 4 Oct 2018 18:47:30 +0000 (-0700) Subject: Merge branch 'master' of git.freeside.biz:/home/git/freeside X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=e937cde6e36499260e2c37704a623091743c810f;hp=d5988a9f7a3617de33da3058f2e9f1151b24420e;p=freeside.git Merge branch 'master' of git.freeside.biz:/home/git/freeside --- diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 6cb0a7cc4..365a42b87 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -87,8 +87,6 @@ sub skin_info { my($context, $session, $custnum) = _custoragent_session_custnum($p); #return { 'error' => $session } if $context eq 'error'; - my $domain = $session->{'domain'}; - my $agentnum = ''; if ( $context eq 'customer' && $custnum ) { @@ -107,7 +105,7 @@ sub skin_info { $p->{'agentnum'} = $agentnum; my $conf = new FS::Conf; - my $timeout = $conf->config('selfservice-session_timeout') || '1 hour'; + #false laziness w/Signup.pm my $skin_info_cache_agent = _cache->get("skin_info_cache_agent$agentnum"); @@ -122,8 +120,6 @@ sub skin_info { warn "$me populating skin info cache for agentnum $agentnum\n" if $DEBUG > 1; - my $menu = $conf->config("ng_selfservice-menu", $agentnum ); - $skin_info_cache_agent = { 'agentnum' => $agentnum, ( map { $_ => scalar( $conf->config($_, $agentnum) ) } @@ -147,93 +143,7 @@ sub skin_info { ( map { $_ => join("\n", $conf->config("selfservice-$_", $agentnum ) ) } qw( head body_header body_footer company_address ) ), 'money_char' => $conf->config("money_char") || '$', - 'menu' => _menu($domain,$menu), - }; - - _cache->set("skin_info_cache_agent$agentnum", $skin_info_cache_agent, $timeout); - - } - - #{ %$skin_info_cache_agent }; - $skin_info_cache_agent; - -} - -## checks if page is in menu listing, if not sends to main with error. -sub check_access { - my $p = shift; - my $error; - - return if $p->{'page'} eq "index.php"; - return if $p->{'page'} eq "ip_login.php"; - - return if substr($p->{'page'}, 0, length("process_")) eq "process_"; - - my $conf = new FS::Conf; - - my($context, $session, $custnum) = _custoragent_session_custnum($p); - - my $domain = ref($session) ? $session->{'domain'} : ''; - - my $agentnum = ''; - if ( $context eq 'customer' && $custnum ) { - - my $sth = dbh->prepare('SELECT agentnum FROM cust_main WHERE custnum = ?') - or die dbh->errstr; - - $sth->execute($custnum) or die $sth->errstr; - - $agentnum = $sth->fetchrow_arrayref->[0] - or die "no agentnum for custnum $custnum"; - - #} elsif ( $context eq 'agent' ) { - } elsif ( defined($p->{'agentnum'}) and $p->{'agentnum'} =~ /^(\d+)$/ ) { - $agentnum = $1; - } - $p->{'agentnum'} = $agentnum; - - my $menu = $conf->config("ng_selfservice-menu", $agentnum ); - - my $allowed_pages = _menu($domain,$menu); - - my %allowed; - my @lines = split /\n/, $allowed_pages; - foreach my $line (@lines) { - chomp; # remove newlines - $line =~ s/^\s+//; # remove leading whitespace - next unless length($line); - my (@pages) = split(/ /, $line, 2); - $allowed{$pages[0]} = $pages[1]; - } - - $error = "You do not have access to the page ".$allowed{$p->{page}} unless $allowed{$p->{page}}; - - return { 'error' => $error, }; - -} - -sub _menu { - my $p = shift; - my $m = shift; - - my $menu; - - if ($p eq 'ip_mac') { - $menu = 'main.php Home - - payment.php Payments - payment_cc.php Credit Card Payment - payment_ach.php Electronic Check Payment - payment_paypal.php PayPal Payment - payment_webpay.php Webpay Payments - - docs.php FAQs - - logout.php Logout - '; - } - else { - $menu = join("\n", $m ) || + 'menu' => join("\n", $conf->config("ng_selfservice-menu", $agentnum ) ) || 'main.php Home services.php Services @@ -262,31 +172,16 @@ sub _menu { docs.php FAQs logout.php Logout - '; - } - return $menu; -} - -sub get_mac_address { - my $p = shift; + ', + }; -## access radius exports acct tables to get mac - my @part_export = (); - @part_export = ( - qsearch( 'part_export', { 'exporttype' => 'sqlradius' } ), - qsearch( 'part_export', { 'exporttype' => 'sqlradius_withdomain' } ), - qsearch( 'part_export', { 'exporttype' => 'broadband_sqlradius' } ), - ); + _cache->set("skin_info_cache_agent$agentnum", $skin_info_cache_agent); - my @sessions; - foreach my $part_export (@part_export) { - push @sessions, ( @{ $part_export->usage_sessions( { - 'ip' => $p->{'ip'}, - 'session_status' => 'open', - } ) } ); } - return { 'mac_address' => $sessions[0]->{'callingstationid'}, }; + #{ %$skin_info_cache_agent }; + $skin_info_cache_agent; + } sub login_info { @@ -296,8 +191,8 @@ sub login_info { my %info = ( %{ skin_info($p) }, - 'phone_login' => $conf->exists('selfservice_server-phone_login'), - 'single_domain' => scalar($conf->config('selfservice_server-single_domain')), + 'phone_login' => $conf->exists('selfservice_server-phone_login'), + 'single_domain'=> scalar($conf->config('selfservice_server-single_domain')), 'banner_url' => scalar($conf->config('selfservice-login_banner_url')), 'banner_image_md5' => md5_hex($conf->config_binary('selfservice-login_banner_image')), @@ -342,22 +237,6 @@ sub login { $svc_x = $svc_phone; - } elsif ( $p->{'domain'} eq 'ip_mac' ) { - - return { error => 'MAC address empty '.$p->{'username'} } - unless $p->{'username'}; - - my $mac_address = $p->{'username'}; - $mac_address =~ s/[\:\,\-\. ]//g; - $mac_address =~ tr/[a-z]/[A-Z/; - - my $svc_broadband = qsearchs( 'svc_broadband', { 'mac_addr' => $mac_address } ); - return { error => 'MAC address not found '.$p->{'username'} } - unless $svc_broadband; - $svc_x = $svc_broadband; - - $session->{'domain'} = $p->{'domain'}; - } elsif ( $p->{email} && (my $contact = FS::contact->by_selfservice_email($p->{email})) ) diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index fefa577b7..dcf34fdaa 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -227,8 +227,6 @@ sub ss2clientapi { 'quotation_add_pkg' => 'MyAccount/quotation/quotation_add_pkg', 'quotation_remove_pkg' => 'MyAccount/quotation/quotation_remove_pkg', 'quotation_order' => 'MyAccount/quotation/quotation_order', - 'get_mac_address' => 'MyAccount/get_mac_address', - 'check_access' => 'MyAccount/check_access', 'freesideinc_service' => 'Freeside/freesideinc_service', }; diff --git a/ng_selfservice/elements/header.php b/ng_selfservice/elements/header.php index 3ef5c6e12..633996515 100644 --- a/ng_selfservice/elements/header.php +++ b/ng_selfservice/elements/header.php @@ -1,21 +1,3 @@ -check_access( array( - 'session_id' => $_COOKIE['session_id'], - 'page' => $page, -) ); - -if ($access['error']) { - header('Location:no_access.php?error='. urlencode($access['error'])); - die(); -} - -?> - diff --git a/ng_selfservice/index.php b/ng_selfservice/index.php index 06e8fc13b..62b6562c8 100644 --- a/ng_selfservice/index.php +++ b/ng_selfservice/index.php @@ -3,7 +3,7 @@ require('freeside.class.php'); $freeside = new FreesideSelfService(); -$login_info = $freeside->login_info( array('session_id' => $_COOKIE['session_id'],)); +$login_info = $freeside->login_info(); extract($login_info); @@ -60,7 +60,7 @@ if ( $error ) { OR

- +
@@ -85,10 +85,6 @@ if ( $error ) { - - diff --git a/ng_selfservice/ip_login.php b/ng_selfservice/ip_login.php deleted file mode 100644 index 153065767..000000000 --- a/ng_selfservice/ip_login.php +++ /dev/null @@ -1,105 +0,0 @@ -get_mac_address( array('ip' => $ip, ) ); - -$response = $freeside->login( array( - 'username' => $mac['mac_address'], - 'domain' => 'ip_mac', -) ); - -$error = $response['error']; - -if ( $error ) { - - $title ='Login'; include('elements/header.php'); - include('elements/error.php'); - echo "Sorry "+$error; - - // header('Location:index.php?username='. urlencode($mac). - // '&domain='. urlencode($domain). - // '&email='. urlencode($email). - // '&error='. urlencode($error) - // ); - -} -else { -// sucessful login - -$session_id = $response['session_id']; - -error_log("[login] logged into freeside with session_id=$session_id, setting cookie"); - -// now what? for now, always redirect to the main page (or the select a -// customer diversion). -// eventually, other options? - -setcookie('session_id', $session_id); - -if ( $response['custnum'] || $response['svcnum'] ) { - - header("Location:main.php"); - die(); - //1; - -} elseif ( $response['customers'] ) { - //var_dump($response['customers']); -?> - - - - - - - -
- - - - - - - - - - -
Customer - -
-
- - - - - - diff --git a/ng_selfservice/no_access.php b/ng_selfservice/no_access.php deleted file mode 100644 index b13cca93c..000000000 --- a/ng_selfservice/no_access.php +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Access Denied - - - - - - - Access Denied -

- -customer_info_short( array( - 'session_id' => $_COOKIE['session_id'], -) ); - -if ( isset($customer_info['error']) && $customer_info['error'] ) { - $error = $customer_info['error']; - header('Location:index.php?error='. urlencode($error)); - die(); -} - -extract($customer_info); - -?> - -

Sorry you do not have access to the page you are trying to reach.

- - - \ No newline at end of file diff --git a/ng_selfservice/process_login.php b/ng_selfservice/process_login.php index d98281a1a..15b000b14 100644 --- a/ng_selfservice/process_login.php +++ b/ng_selfservice/process_login.php @@ -3,13 +3,6 @@ require('freeside.class.php'); $freeside = new FreesideSelfService(); -$ip = $_SERVER['REMOTE_ADDR']; - -if ($_POST['domain'] == "ip_mac") { - $mac_addr = $freeside->get_mac_address( array('ip' => $ip, ) ); - $_POST['username'] = $mac_addr['mac_address']; -} - $response = $freeside->login( array( 'email' => strtolower($_POST['email']), 'username' => strtolower($_POST['username']), @@ -23,9 +16,9 @@ $error = $response['error']; if ( $error ) { - header('Location:index.php?username='. urlencode($_POST['username']). - '&domain='. urlencode($_POST['domain']). - '&email='. urlencode($_POST['email']). + header('Location:index.php?username='. urlencode($username). + '&domain='. urlencode($domain). + '&email='. urlencode($email). '&error='. urlencode($error) ); die(); @@ -50,7 +43,7 @@ if ( $response['custnum'] || $response['svcnum'] ) { die(); } elseif ( $response['customers'] ) { - //var_dump($response['customers']); +var_dump($response['customers']); ?>