vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=235)
-   -   Login by username or email (https://vborg.vbsupport.ru/showthread.php?t=96832)

Marco van Herwaarden 09-23-2005 10:00 PM

Login by username or email
 
1 Attachment(s)
This code modification was made as part of a request in this thread: https://vborg.vbsupport.ru/showthrea...5&page=1&pp=15

All that it does is allow to use the email address instead of the username to be used to login (username also still works).

Since people where stating that it should be released, well here it goes.

1 File edit:
in file includes/functions_login.php, find:
PHP Code:

    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)) . "'")) 

and replace by:
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)) . "'"))
{
$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) 

This will allow logging in with either mail or username.

nexialys 09-24-2005 07:14 PM

good idea, anyway, this is only a if statement to add, so it's not complicated to enhance if needed (like register by email only...)

Marco van Herwaarden 09-24-2005 07:24 PM

email only would even be easier, just replace 1 word in the original file.

Lurk 09-24-2005 07:31 PM

Wow, this is awesome.. except I won't be using it, maybe later. I like the concept and idea, it can be like a passport system if you integrate it into many sites. ;) :p

Marco van Herwaarden 09-24-2005 07:36 PM

Just a pitty it has to be a code change.

deathemperor 09-25-2005 02:07 PM

how about extend this to allow userid logging ?

Marco van Herwaarden 09-25-2005 03:58 PM

How you mean? Log what about a userid?

This is a simple code mod that make it possible to login with email address, there is no logging involved in this, and there won't be also.

nexialys 09-25-2005 04:08 PM

i think he was referring to login via with our userid indead of email or username... this becomes a little useless here... who remembers their userid better than their username?!

Marco van Herwaarden 09-25-2005 07:10 PM

Lol, well logging in with userid could be done the same way, but it won't be easier to remember.

deathemperor 09-26-2005 06:41 AM

Quote:

Originally Posted by nexialys
i think he was referring to login via with our userid indead of email or username... this becomes a little useless here... who remembers their userid better than their username?!

me and most of my member

ppl who have joined for a long period of time would remember it.

well whatever, just an idea

Marco van Herwaarden 09-26-2005 07:02 AM

just replace email with userid and you're done.

mikehawk 11-09-2005 06:54 PM

Register by email would be good as well...

dcpaq2xx 01-05-2006 09:18 PM

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.

Doug

Marco van Herwaarden 01-19-2006 06:30 PM

Quote:

Originally Posted by dcpaq2
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.

Tim Simms 05-12-2006 05:37 PM

Maybe instead of:
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)) . "'"))
{
$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... :confused:

Marco van Herwaarden 05-13-2006 09:01 AM

That is a good suggestion and i might add it to a next (??) release.

Smiry Kin's 05-25-2006 07:19 AM

does this work on 3.5.4?

BaBa2002 05-28-2006 07:14 AM

Quote:

Originally Posted by MarcoH64
email only would even be easier, just replace 1 word in the original file.

what do you mean with just replace 1 word?
for just email registration? and witch word?

xr8d76 06-04-2006 07:56 AM

where/how do you add on the login boxes, instead of it just showing:

username:
Password:

TO

Username/Email:
Password:

Pls and thx

Smiry Kin's 06-04-2006 08:54 AM

Quote:

Originally Posted by xr8d76
where/how do you add on the login boxes, instead of it just showing:

username:
Password:

TO

Username/Email:
Password:

Pls and thx

search parse "User Name"

maybe?

futuredood 06-21-2006 07:19 PM

how do you change this to ONLY e-mail, and does it work for 3.5.4?

futuredood 06-22-2006 08:02 AM

to note this works with 3.5.4

malmazan 11-29-2006 08:53 AM

These days (3.6.4) it is more like:
Loor for :
PHP Code:

if ($vbulletin->userinfo $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '" $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'")) 

And replace by:

PHP Code:

// Start hack login with mail address (MarcoH64 Marco van Herwaarden)
// original 3 6 4 add infractiongroup ids to original hack    if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 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, infractiongroupids, 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, infractiongroupids, 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 Marco van Herwaarden) 

It's the same thing, though "infractiongroupids, " is added to the query list

OneEyeSleepy 04-03-2008 04:13 PM

Hi, is there anything similar that can be used for vbulletin v3.6.9?

Hasann 04-03-2008 04:25 PM

Heyy Marco does it work for 3.7.x ?

abendagar 04-05-2008 09:56 AM

Any downside to using

if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "' OR email = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))

Isn't it simpler???

malmazan 05-10-2008 07:38 PM

Quote:

Originally Posted by Hasann (Post 1482108)
Heyy Marco does it work for 3.7.x ?

It works

ChrisXX 08-14-2008 05:03 PM

So let me get this straight, if I just change this...

Code:

    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)) . "'"))
to this...

Code:

    if ($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)) . "'"))
It will force users to login with their email address, instead of their username?

My goal is to make the username benign, and only for display purposes. The reason is I will be integrating VB in with some other apps that require email, and also use a username but only for display purposes.

Am I correct?

My second question then becomes, if two users have the same display name (for vB, username), will it cause problems? If so, is there a way to rectify that?

Thanks much in advance!

Arkham 09-03-2008 10:25 PM

Hi folks -- long time no see...

Just a quick question: Does this hack still work with the current vB release?

jerx 10-15-2008 02:30 PM

Works on vb 3.7.3 pl1. This is the code I used:

Code:

// Start hack login with mail address (MarcoH64)
//        if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 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, infractiongroupids, 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, infractiongroupids, 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

Quote:

Originally Posted by abendagar (Post 1483454)
Any downside to using

if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "' OR email = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))

Isn't it simpler???

That works, too. Are there any differences between both versions, eg performance, security or stability wise?

TheFocusElf 12-18-2008 07:47 PM

I am currently using VB 3.74, I have not upgraded to PL1, but I will in a short moment. I don't know how many users have had any resolution to this, and I was nervous for a fraction of a second before I read through the mod and really took a moment to understand what it was doing:

I am a Director of Marketing and training for a modest NFP organization, our initiatives are funded by our member dues, plain and simple. We are planning to open up the site from a pretty non-interactive VB to a defined VB system with users actually entering the system, belonging to member classes, etc. For record keeping, we want our members to log in with their emails, this way, if something changed significantly, they might be inclined to modify their email address in their control panel so that we're all up to date.

So, if you are looking to EXLUSIVELY require your members to log in with their emails (don't forget, this changes the Admin CP log in too), open the prescribed file in the original post, and if the file is otherwise unmodified, scroll down to around line 140, this is where you will find :

Code:

if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))
Comment that out with // and substitute the following:
Code:

if $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)) . "'");
All of these instructions were contained in the original post, just probably a few of you users, like me, don't really know what all is going on in those lines of code!

Again, this works, and unless VB drastically overhauls the login system, I see this very simple process working for patches to come.

Cheers and Merry Christmas/Holidays and Happy New Year!

sharkee 05-29-2009 09:31 PM

Great, thanks. Installed.

asiaphoto 01-12-2010 02:41 AM

hi everyone,

now that VB4 is released (and i'm running our forum on VB4)

is anyone able to update this mod? i'm willing to pay for professional service.

see my request here:
https://vborg.vbsupport.ru/showthrea...17#post1953217

phoelapyae 11-30-2010 05:26 PM

Can i get for version 4?

malmazan 12-14-2010 04:35 PM

Vote on vB.com to have this feature made standard: http://tracker.vbulletin.com/browse/VBIV-9646

davidthornton 09-12-2011 04:45 AM

Does anyone have this working for v4.x? I'd like to be able to change a v4.x installation to only allow login via email address instead of username (and have the forum only permit one account per email address as well)

imedic 10-17-2011 09:09 PM

Quote:

Originally Posted by jerx (Post 1645619)
Works on vb 3.7.3 pl1. This is the code I used:

Code:

// Start hack login with mail address (MarcoH64)
//        if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 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, infractiongroupids, 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, infractiongroupids, 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



That works, too. Are there any differences between both versions, eg performance, security or stability wise?


I can confirm that ONLY the above code works for 3.8.5 too :)

I add that you also need to change Username to Name/email. Look in language for: <strong>$vbphrase[username]</strong>
Then Look for template register and search in it for: <strong>$vbphrase[username]</strong> and change it to <strong>$vbphrase[user_name]</strong>
This will keep in register template the phrase Username and in login box Name/Email.
If you don't do this modification You will have allot of users registering with email address instead of Username.

Thanks

imedic 12-10-2011 02:15 PM

There is a small bug ( a space between - and > ) and gives an error if you upgrade to 3.8.7 PL2 so here is the working code I use:

PHP Code:

 // Start hack login with mail address (MarcoH64)
//  if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid,  membergroupids, infractiongroupids, 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, infractiongroupids, 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, infractiongroupids, 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 


HMBeaty 12-10-2011 04:54 PM

I have not tested this, but in vBulletin 4, try this:

In the file includes/functions_login.php, find:
PHP Code:

    if ($vbulletin->userinfo $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '" $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'")) 

And replace with:
PHP Code:

//    Start hack login with mail address (MarcoH64)
//    if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 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, infractiongroupids, 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, infractiongroupids, 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) 


malmazan 12-14-2011 08:53 PM

Quote:

Originally Posted by HMBeaty (Post 2276545)
I have not tested this, but in vBulletin 4, try this:

In the file includes/functions_login.php, find:
PHP Code:

    if ($vbulletin->userinfo $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '" $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'")) 

And replace with:
PHP Code:

//    Start hack login with mail address (MarcoH64)
//    if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 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, infractiongroupids, 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, infractiongroupids, 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) 


Did you change anything with respect to the latest v3 versions? I'm getting this error on v4.1.8:
Code:

Fatal error: Cannot redeclare fetch_replaced_session_url() (previously declared in root/includes/functions_login.php:14) in root/includes/functions_login.php on line 568


All times are GMT. The time now is 01:05 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01583 seconds
  • Memory Usage 1,919KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (11)bbcode_php_printable
  • (8)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete