commit ff5ee429de126560b610449168da3a28a03009e2
Author: Olivier Bilodeau <olivier@bottomlesspit.org>
Date:   Wed Aug 15 16:54:50 2012 -0400

    quickly fixing sponsored guests regressions (#1505)
    
    A clean and complete, API changing, fix will come in devel.

diff --git a/html/captive-portal/guest-selfregistration.cgi b/html/captive-portal/guest-selfregistration.cgi
index 20d4c8f..3803955 100755
--- a/html/captive-portal/guest-selfregistration.cgi
+++ b/html/captive-portal/guest-selfregistration.cgi
@@ -70,6 +70,11 @@ if (defined($cgi->url_param("preregistration")) && $cgi->url_param("preregistrat
 if ($session->param("preregistration")) {
     $portalSession->setGuestNodeMac(undef);
 }
+# Assigning MAC as guest MAC
+# FIXME quick and hackish fix for #1505. A proper, more intrusive, API changing, fix should hit devel.
+else {
+    $portalSession->setGuestNodeMac($portalSession->getClientMac());
+}
 
 if (defined($cgi->url_param('mode')) && $cgi->url_param('mode') eq $GUEST_REGISTRATION) {
 
@@ -111,7 +116,7 @@ if (defined($cgi->url_param('mode')) && $cgi->url_param('mode') eq $GUEST_REGIST
 
       # TODO this portion of the code should be throttled to prevent malicious intents (spamming)
       ($auth_return, $err, $errargs_ref) = pf::email_activation::create_and_email_activation_code(
-          $portalSession->getClientMac(), $info{'pid'}, $info{'pid'}, 
+          $portalSession->getGuestNodeMac(), $info{'pid'}, $info{'pid'}, 
           ( $session->param("preregistration") 
               ? $pf::web::guest::TEMPLATE_EMAIL_EMAIL_PREREGISTRATION
               : $pf::web::guest::TEMPLATE_EMAIL_GUEST_ACTIVATION 
@@ -142,7 +147,7 @@ if (defined($cgi->url_param('mode')) && $cgi->url_param('mode') eq $GUEST_REGIST
 
       # User chose to register by SMS
       $logger->info("registering " . $portalSession->getClientMac() . " guest by SMS " . $session->param("phone") . " @ " . $cgi->param("mobileprovider"));
-      ($auth_return, $err, $errargs_ref) = sms_activation_create_send($portalSession->getClientMac(), $session->param("phone"), $cgi->param("mobileprovider") );
+      ($auth_return, $err, $errargs_ref) = sms_activation_create_send($portalSession->getGuestNodeMac(), $session->param("phone"), $cgi->param("mobileprovider") );
       if ($auth_return) {
 
           # form valid, adding person (using modify in case person already exists)
@@ -198,7 +203,8 @@ if (defined($cgi->url_param('mode')) && $cgi->url_param('mode') eq $GUEST_REGIST
 
       # TODO this portion of the code should be throttled to prevent malicious intents (spamming)
       ($auth_return, $err, $errargs_ref) = pf::email_activation::create_and_email_activation_code(
-          $portalSession->getClientMac(), $info{'pid'}, $info{'sponsor'}, $pf::web::guest::TEMPLATE_EMAIL_SPONSOR_ACTIVATION,
+          $portalSession->getGuestNodeMac(), $info{'pid'}, $info{'sponsor'}, 
+          $pf::web::guest::TEMPLATE_EMAIL_SPONSOR_ACTIVATION,
           $pf::email_activation::SPONSOR_ACTIVATION,
           %info
       );
diff --git a/lib/pf/Portal/Session.pm b/lib/pf/Portal/Session.pm
index 0c92ddb..16e88bf 100644
--- a/lib/pf/Portal/Session.pm
+++ b/lib/pf/Portal/Session.pm
@@ -183,7 +183,7 @@ Sets the guest node mac address in the case of an email activation.
 sub setGuestNodeMac {
     my ($self, $guest_node_mac) = @_;
 
-    $self->{'_guest_node_mac'} = clean_mac($guest_node_mac);
+    $self->{'_guest_node_mac'} = $guest_node_mac;
 }
 
 =back
diff --git a/lib/pf/web.pm b/lib/pf/web.pm
index 2d55915..053bb0e 100644
--- a/lib/pf/web.pm
+++ b/lib/pf/web.pm
@@ -532,7 +532,15 @@ sub web_node_register {
     # First blast at consuming portalSession object
     my $cgi     = $portalSession->getCgi();
     my $session = $portalSession->getSession();
-    my $mac     = $portalSession->getClientMac() if (!defined($portalSession->getGuestNodeMac()));
+
+    # FIXME quick and hackish fix for #1505. A proper, more intrusive, API changing, fix should hit devel.
+    my $mac;
+    if (defined($portalSession->getGuestNodeMac)) {
+        $mac = $portalSession->getGuestNodeMac;
+    }
+    else {
+        $mac = $portalSession->getClientMac;
+    }
 
     if ( is_max_reg_nodes_reached($mac, $pid, $info{'category'}) ) {
         pf::web::generate_error_page(
