Show
Ignore:
Timestamp:
02/25/10 15:56:33 (2 years ago)
Author:
gbastien
Message:
  • Added possibility to have a deployed geolocated node not show on map (quick fix) (#706)
  • When producing anonymised data export, two files are produced, one for the geolocated nodes and one for the connections (#705)
  • Additions and bug fixes to web service: can now logout and auth returns both error code and message
  • Starting work on #707 as needed
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/ws/classes/WifidogWS/V1.php

    r1439 r1453  
    103103                        'NumOnlineUsers' => 'NumOnlineUsers', 
    104104                        'CreationDate' => 'CreationDate', 
    105                         'Status' => 'Status', 
     105                        'Status' => 'DeploymentStatus', 
    106106                        'OpeningDate' => 'CreationDate',  
    107107                                                                        'Connected_users' => 'OnlineUsers'), 
     
    150150        foreach($infields as $field) { 
    151151            if (isset(self::$_allowedFields[$objectClass][$field])) 
    152                 $fields[] = self::$_allowedFields[$objectClass][$field]; 
     152                $fields[$field] = self::$_allowedFields[$objectClass][$field]; 
    153153            else 
    154                 $fields[] = "$field.forbidden"; 
     154                $fields[$field] = "$field.forbidden"; 
    155155        } 
    156156        return $fields; 
     
    189189                $username = (isset($this->_params['username']) ? $this->_params['username']:''); 
    190190                $password = (isset($this->_params['password']) ? $this->_params['password']:''); 
    191                 $this->executeAuth($username, $password, $gw_id, $gw_address, $mac, $gw_port, $from); 
     191                $logout = (isset($this->_params['logout']) ? $this->_params['logout']:false); 
     192                $this->executeAuth($username, $password, $gw_id, $gw_address, $mac, $gw_port, $from, $logout); 
    192193                break; 
    193194            default: 
     
    204205     * @param $gw_id      The gateway id 
    205206     * @param $gw_ip      The gateway's ip addresss 
     207     * @param $mac                        The mac address of the user 
     208     * @param $gw_port    The port of the gateway's http server 
     209     * @param $from                     The ip address of the user on the node 
     210     * @param $logout                   Whether the user wants to logout 
    206211     * @return unknown_type 
    207212     */ 
    208     protected function executeAuth($username = null, $password = null, $gw_id = null, $gw_ip = null, $mac = null, $gw_port = null, $from = null) { 
     213    protected function executeAuth($username = null, $password = null, $gw_id = null, $gw_ip = null, $mac = null, $gw_port = null, $from = null, $logout = false) { 
    209214        $this->_outputArr['auth'] = 0; 
    210215         
     
    240245            if (!$token) throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR); 
    241246        } else { 
    242             // Authenticate the user on the requested network 
    243             $user = $network->getAuthenticator()->login($username, $password, $errMsg); 
    244             if (!$user) { 
    245                 $this->_outputArr['auth'] = 0; 
    246                 $this->_outputArr['explanation'] = $errMsg; 
     247            if (!$logout) { 
     248                // Authenticate the user on the requested network 
     249                $user = $network->getAuthenticator()->login($username, $password, $errMsg, $errNo); 
     250                if (!$user) { 
     251                    $this->_outputArr['auth'] = 0; 
     252                    $this->_outputArr['explanation'] = $errMsg; 
     253                    $this->_outputArr['errorcode'] = $errNo; 
     254                } else { 
     255                    $this->_outputArr['auth'] = 1; 
     256                    if (!is_null($node)) { 
     257                        $token = $user->generateConnectionTokenNoSession($node, $from, $mac); 
     258                        
     259                        if (!$token) throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR); 
     260                    } 
     261                } 
    247262            } else { 
     263                $user = User::getUserByUsernameOrEmail($username); 
     264                User::setCurrentUser($user); 
     265                $network->getAuthenticator()->logout(); 
    248266                $this->_outputArr['auth'] = 1; 
    249                 if (!is_null($node)) { 
    250                     $token = $user->generateConnectionTokenNoSession($node, $from, $mac); 
    251                     
    252                     if (!$token) throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR); 
    253                 } 
    254267            } 
    255268        } 
     
    298311        $fields = $this->mapFields($objectClass, $fields); 
    299312        if (empty($fields)) { 
    300             $fields = array_keys(self::$_allowedFields[$objectClass]); 
     313            $fields = self::$_allowedFields[$objectClass]; 
    301314        }  
    302315        $allowedFields = self::$_allowedFields[$objectClass]; 
     
    362375        }  
    363376 
     377        if (!isset($objectList)) { 
     378            throw new WSException("Object list for '{$objectClass}' is not supported.", WSException::GENERIC_EXCEPTION); 
     379        } 
    364380        $this->_outputArr = self::filterRet($objectList, $fields); 
    365381    } 
     
    389405                    } 
    390406                    $retFields = array(); 
    391                     foreach ($fields as $field) { 
     407                    foreach ($fields as $fkey => $field) { 
    392408                        $forbiddenfield = explode(".", $field); 
    393409                        if (! (count($forbiddenfield) == 2)) { 
    394410                            $methodName = 'get'.$field; 
    395411                            if (method_exists($value, $methodName)) { 
    396                                  
    397                                 $retFields[$field] = self::filterRet($value->$methodName()); 
     412                                $retFields[is_string($fkey)?$fkey:$field] = self::filterRet($value->$methodName()); 
    398413                            } else { 
    399                                 $retFields[$field] = 'unknown'; 
     414                                $retFields[is_string($fkey)?$fkey:$field] = 'unknown'; 
    400415                            } 
    401416                        } else