Show
Ignore:
Timestamp:
07/21/07 00:59:33 (5 years ago)
Author:
benoitg
Message:
  • At long last, implement #9: Automatic new node creation. When attempting to login from an unknown node, the user (if he has the permissions) will be prompted to create the node, or "steal" en existing one (for hardware swaps).
  • Refactor Node:getSelectNodeUI().
  • Menu.php: Fix small oversight causing menu not to clear.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/login/index.php

    r1249 r1261  
    132132    try { 
    133133        $node = Node::getObjectByGatewayId($gw_id); 
    134         if($node) 
    135         { 
    136             $session->set(SESS_NODE_ID_VAR, $node->getId()); 
     134    } 
     135 
     136    catch (Exception $e) { 
     137        $returnedNodeIsNew = false; 
     138        $node = Node::processStealOrCreateNewUI($gw_id, $returnedNodeIsNew); 
     139 
     140        if(!$node){ 
     141            $ui = MainUI::getObject(); 
     142            $ui->addContent('main_area_middle', '<p class=errormsg>'.$e->getMessage()."</p>\n", 1); 
     143            $stealNodeForm=null; 
     144            $stealNodeForm.="<form action='' method='POST'>\n"; 
     145            $stealNodeForm.=Node::getStealOrCreateNewUI($gw_id); 
     146            $stealNodeForm.="</form>\n"; 
     147            $ui->addContent('main_area_middle',$stealNodeForm,2); 
     148            $ui->display(); 
     149            exit; 
    137150        } 
    138     } 
    139  
    140     catch (Exception $e) { 
    141         $ui = MainUI::getObject(); 
    142         $ui->displayError($e->getMessage()); 
    143         exit; 
    144     } 
    145  
     151        else { 
     152            if($returnedNodeIsNew) { 
     153                $url = BASE_URL_PATH."admin/generic_object_admin.php?object_class=Node&action=edit&object_id=".$node->getId(); 
     154                header("Location: {$url}"); 
     155                exit; 
     156            } 
     157        } 
     158    } 
     159    if($node) 
     160    { 
     161        $session->set(SESS_NODE_ID_VAR, $node->getId()); 
     162    } 
    146163    $network = $node->getNetwork(); 
    147164} else {