Show
Ignore:
Timestamp:
03/14/10 18:42:49 (3 years ago)
Author:
gbastien
Message:

Performance enhancement: better queries and indexes for case-insensitivity. One connection/request to server, content logging can now be turned off if desired.

Files:
1 modified

Legend:

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

    r1453 r1456  
    126126            $password = $db->escapeString($password); 
    127127             
    128             $comparison = ($this->getNetwork()->getUsernamesCaseSensitive()? ' = ': ' ILike '); 
    129             $sql = "SELECT user_id FROM users WHERE (username$comparison'$username' OR email$comparison'$username') AND account_origin='".$this->getNetwork()->getId()."' AND pass='$password_hash'"; 
     128            $username = ($this->getNetwork()->getUsernamesCaseSensitive()? $username: strtolower($username)); 
     129            $compareto = ($this->getNetwork()->getUsernamesCaseSensitive()? 'username' : 'lower(username)'); 
     130            $sql = "SELECT user_id FROM users WHERE ($compareto = '$username' OR lower(email) = '$username') AND account_origin='".$this->getNetwork()->getId()."' AND pass='$password_hash'"; 
    130131            $db->execSqlUniqueRes($sql, $user_info, false); 
    131132 
     
    146147                 */ 
    147148                $user_info = null; 
    148                 $db->execSqlUniqueRes("SELECT * FROM users WHERE (username$comparison'$username' OR email$comparison'$username') AND account_origin='".$this->getNetwork()->getId()."'", $user_info, false); 
     149                $db->execSqlUniqueRes("SELECT * FROM users WHERE ($compareto = '$username' OR lower(email) = '$username') AND account_origin='".$this->getNetwork()->getId()."'", $user_info, false); 
    149150 
    150151                if ($user_info == null) {