Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Thu, 4 Oct 2018 18:47:30 +0000 (11:47 -0700)
committerIvan Kohler <ivan@freeside.biz>
Thu, 4 Oct 2018 18:47:30 +0000 (11:47 -0700)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/ClientAPI_XMLRPC.pm
ng_selfservice/elements/header.php
ng_selfservice/index.php
ng_selfservice/ip_login.php [deleted file]
ng_selfservice/no_access.php [deleted file]
ng_selfservice/process_login.php

index 6cb0a7c..365a42b 100644 (file)
@@ -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}))
           )
index fefa577..dcf34fd 100644 (file)
@@ -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',
   };
index 3ef5c6e..6339965 100644 (file)
@@ -1,21 +1,3 @@
-<?
-
-require_once('session.php');
-
-$page = basename($_SERVER['SCRIPT_FILENAME']);
-
-$access = $freeside->check_access( array(
-  'session_id' => $_COOKIE['session_id'],
-  'page'       => $page,
-) );
-
-if ($access['error']) {
-  header('Location:no_access.php?error='. urlencode($access['error']));
-  die();
-}
-
-?>
-
 <!DOCTYPE html>
 <HTML>
   <HEAD>
index 06e8fc1..62b6562 100644 (file)
@@ -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 ) {
 <? if ( $phone_login ) { ?>
 
   <B>OR</B><BR><BR>
-
+    
   <FORM ACTION="process_login.php" METHOD=POST>
   <INPUT TYPE="hidden" NAME="session" VALUE="login">
   <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>
@@ -85,10 +85,6 @@ if ( $error ) {
 
 <? } ?>
 
-<!--
-<BR><BR><A HREF="ip_login.php">Login by IP (<? echo $_SERVER['REMOTE_ADDR']; ?>) to make a payment.</A>
--->
-
 <? include('elements/footer.php'); ?>
 
 
diff --git a/ng_selfservice/ip_login.php b/ng_selfservice/ip_login.php
deleted file mode 100644 (file)
index 1530657..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-<?
-
-require('freeside.class.php');
-$freeside = new FreesideSelfService();
-
-$ip = $_SERVER['REMOTE_ADDR'];
-
-$mac = $freeside->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']);
-?>
-
-  <? $title ='Select customer'; include('elements/header.php'); ?>
-  <? include('elements/error.php'); ?>
-
-  <FORM NAME="SelectCustomerForm" ACTION="process_select_cust.php" METHOD=POST>
-  <INPUT TYPE="hidden" NAME="action" VALUE="switch_cust">
-
-  <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>
-
-    <TR>
-      <TH ALIGN="right">Customer </TH>
-      <TD>
-        <SELECT NAME="custnum" ID="custnum" onChange="custnum_changed()">
-          <OPTION VALUE="">Select a customer
-          <? foreach ( $response['customers'] AS $custnum => $customer ) { ?>
-            <OPTION VALUE="<? echo $custnum ?>"><? echo htmlspecialchars( $customer ) ?>
-          <? } ?>
-        </SELECT>
-      </TD>
-    </TR>
-
-    <TR>
-      <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" ID="submit" VALUE="Select customer" DISABLED></TD>
-    </TR>
-
-  </TABLE>
-  </FORM>
-
-  <SCRIPT TYPE="text/javascript">
-
-  function custnum_changed () {
-    var form = document.SelectCustomerForm;
-    if ( form.custnum.selectedIndex > 0 ) {
-      form.submit.disabled = false;
-    } else {
-      form.submit.disabled = true;
-    }
-  }
-
-  </SCRIPT>
-
-<?
-
-// } else {
-// 
-//   die 'login successful, but unrecognized info (no custnum, svcnum or customers)';
-  
-} // multiple customers found
-
-} //successfull login
-
-?>
-
-  <? include('elements/footer.php'); ?>
diff --git a/ng_selfservice/no_access.php b/ng_selfservice/no_access.php
deleted file mode 100644 (file)
index b13cca9..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE html>
-<HTML>
-  <HEAD>
-    <TITLE>
-      Access Denied
-    </TITLE>
-    <link href="css/default.css" rel="stylesheet" type="text/css"/>
-    <script type="text/javascript" src="js/jquery.js"></script>
-    <script type="text/javascript" src="js/menu.js"></script>
-  </HEAD>
-  <BODY>
-    <FONT SIZE=5>Access Denied</FONT>
-    <BR><BR>
-<? $current_menu = 'no_access.php'; include('elements/menu.php'); ?>
-<?
-
-$customer_info = $freeside->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);
-
-?>
-
-<P>Sorry you do not have access to the page you are trying to reach.</P>
-
-<? include('elements/menu_footer.php'); ?>
-<? include('elements/footer.php'); ?>
\ No newline at end of file
index d98281a..15b000b 100644 (file)
@@ -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']);
 ?>
 
   <? $title ='Select customer'; include('elements/header.php'); ?>