diff options
-rw-r--r-- | program/include/rcube_user.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php index 0c044cadf..a57d67118 100644 --- a/program/include/rcube_user.php +++ b/program/include/rcube_user.php @@ -326,16 +326,18 @@ class rcube_user { $dbh = rcmail::get_instance()->get_dbh(); - // query if user already registered - $sql_result = $dbh->query( - "SELECT * FROM ".get_table_name('users')." - WHERE mail_host=? AND (username=? OR alias=?)", - $host, - $user, - $user); - + // query for matching user name + $query = "SELECT * FROM ".get_table_name('users')." WHERE mail_host=? AND %s=?"; + $sql_result = $dbh->query(sprintf($query, 'username'), $host, $user); + + // query for matching alias + if (!($sql_arr = $dbh->fetch_assoc($sql_result))) { + $sql_result = $dbh->query(sprintf($query, 'alias'), $host, $user); + $sql_arr = $dbh->fetch_assoc($sql_result); + } + // user already registered -> overwrite username - if ($sql_arr = $dbh->fetch_assoc($sql_result)) + if ($sql_arr) return new rcube_user($sql_arr['user_id'], $sql_arr); else return false; |