I was doing some playing around with this hack and something that I noticed was that if you have more than one user name assigned to the same email address it cannot tell which one to login as and it logs you in on the first one in the user id list.
Other than that it seems to work fine.
Thank you for taking the time to create this hack Marco, Im still undecided as of right now though If ill be using this hack or not.
I was doing some playing around with this hack and something that I noticed was that if you have more than one user name assigned to the same email address it cannot tell which one to login as and it logs you in on the first one in the user id list.
Well that would make sense. I don't think this is the right hack if you allow multiple users (although they are probably all the same person) to share 1 mail address.
// Start hack login with mail address (MarcoH64)
// if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))
if (!$vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))
{
$vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE email = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'");
}
if ($vbulletin->userinfo)
// End hack login with mail address (MarcoH64)
...you could do this:
PHP Code:
// Start hack login with mail address (MarcoH64)
// if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))
if (!$vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))
{
if (($result = $vbulletin->db->query("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE email = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'")) && $vbulletin->db->num_rows($result) > 1)
{
// Do some sort of notification to user
// saying that email address is ambiguous
}
else
{
$vbulletin->userinfo = $vbulletin->db->fetch_array($result);
$vbulletin->db->free_result($result);
}
}
I did it on ours, and at least it prevents a shared email address from logging into any of them. Of course, I don't have any feedback to the user, cuz I don't know how...