Show
Ignore:
Timestamp:
06/10/08 00:25:06 (4 years ago)
Author:
benoitg
Message:
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1336 r1350  
    152152     * @param $username The username of the user 
    153153     * @param $account_origin Network:  The account origin 
    154      * @param &$errMsg An error message will be appended to this is the username is not empty, but the user doesn't exist. 
     154     * @param &$errMsg An error message will be appended to this if the username is not empty, but the user doesn't exist. 
    155155     * @return a User object, or null if there was an error 
    156156     */ 
     
    536536                //echo "$session && $node_ip && {$session->get(SESS_NODE_ID_VAR)}"; 
    537537                $node_id = $db->escapeString($session->get(SESS_NODE_ID_VAR)); 
    538                 $db->execSqlUpdate("INSERT INTO connections (user_id, token, token_status, timestamp_in, node_id, node_ip, last_updated) VALUES ('" . $this->getId() . "', '$token', '" . TOKEN_UNUSED . "', CURRENT_TIMESTAMP, '$node_id', '$node_ip', CURRENT_TIMESTAMP)", false); 
     538 
     539                /* 
     540                 * Delete all unused tokens for this user, so we don't fill the database 
     541                 * with them 
     542                 */ 
     543                $sql = "DELETE FROM connections USING tokens "."WHERE tokens.token_id=connections.token_id AND token_status='".TOKEN_UNUSED."' AND user_id = '".$this->getId()."';\n"; 
     544                // TODO:  Try to find a reusable token before creating a brand new one! 
     545                 
     546                $sql .= "INSERT INTO tokens (token_owner, token_issuer, token_id, token_status) VALUES ('" . $this->getId() . "', '" . $this->getId() . "', '$token', '" . TOKEN_UNUSED . "');\n"; 
     547                $sql .= "INSERT INTO connections (user_id, token_id, timestamp_in, node_id, node_ip, last_updated) VALUES ('" . $this->getId() . "', '$token', CURRENT_TIMESTAMP, '$node_id', '$node_ip', CURRENT_TIMESTAMP)"; 
     548                $db->execSqlUpdate($sql, false); 
    539549                $retval = $token; 
    540550            } else