vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Login using email address instead of username v3.8.4 (https://vborg.vbsupport.ru/showthread.php?t=225444)

johnnie198x 10-17-2009 05:06 PM

Login using email address instead of username v3.8.4
 
I want my forum to be setup so that users use their email addresses to login instead of username. I did a search on this forum, and this is the closet to what I wanted:
https://vborg.vbsupport.ru/showthread.php?t=96832

This is for v3.5.0 RC3 and login with either username or email, but I have 3.8.4 PL1 and I want login with email only, not username.

I tried:
File: ./includes/functions_login.php
Line: 140
CHANGED 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 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 didn't seem to work. Can anyone help me with this? Thanks.

Dylanblitz 10-17-2009 05:35 PM

You have to replace it in the strike queries as well, I just tried it and it worked for me. There were 3 places I changed it from username = to email =

johnnie198x 10-17-2009 06:42 PM

Quote:

Originally Posted by Dylanblitz (Post 1901410)
You have to replace it in the strike queries as well, I just tried it and it worked for me. There were 3 places I changed it from username = to email =

I have limited IT skills, so can you be more specific? What are 3 places you changed? Thanks.

Dylanblitz 10-17-2009 08:41 PM

On Line 100
Change

PHP Code:

                AND username '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "' 

to

PHP Code:

                AND email '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "' 


On Line 105

Change

PHP Code:

            if ($user $vbulletin->db->query_first("SELECT userid, username, email, languageid FROM " TABLE_PREFIX "user WHERE username = '" $vbulletin->db->escape_string($username) . "' AND usergroupid <> 3")) 

to

PHP Code:

            if ($user $vbulletin->db->query_first("SELECT userid, username, email, languageid FROM " TABLE_PREFIX "user WHERE email = '" $vbulletin->db->escape_string($username) . "' AND usergroupid <> 3")) 

On Line 140

Change

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

to

PHP Code:

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

I did that and was able to login with my email instead of username. Didn't really test it a lot so don't know if it has any other ramifications with the script in other areas.

johnnie198x 10-17-2009 09:38 PM

Dylanblitz,
Thanks so much for helping me. It worked in the forum, but I think further mod is required for ACP and MCP. Here's the error when logging in ACP:
===============================
Database error in vBulletin 3.8.4:

Invalid SQL:

SELECT COUNT(*) AS strikes
FROM strikes
WHERE strikeip = 'xx.xx'
AND email = 'Administrator';

MySQL Error : Unknown column 'email' in 'where clause'
Error Number : 1054
Request Date : Saturday, October 17th 2009 @ 03:29:49 PM
Error Date : Saturday, October 17th 2009 @ 03:29:49 PM
Script : http://www.xxx.com/login.php?do=login
Referrer : http://www.xxx.com/iamadmin/
IP Address : xx.xx
Username : Administrator
Classname : vB_Database
MySQL Version : 4.1.22-max-log
================================
I hope you can help me with this. Thanks a lot.

Dylanblitz 10-18-2009 03:58 AM

Actually, I found an easier way. Revert what I told you before

in the includes/function_login.php

Find on Line 135

PHP Code:

function verify_authentication($username$password$md5password$md5password_utf$cookieuser$send_cookies)
{
    global 
$vbulletin

After add

PHP Code:

$get_username_query $vbulletin->db->query_read("SELECT username FROM " TABLE_PREFIX "user WHERE email = '" $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'");

    if (
$vbulletin->db->num_rows($get_username_query) > 0)
    {
    
$get_username_data $vbulletin->db->fetch_array($get_username_query);
    
$username $get_username_data[username];
    } 

I did that on 3.8.4PL1 on my local system. I was able to login to the forums and ACP.


All times are GMT. The time now is 02:36 PM.

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.01173 seconds
  • Memory Usage 1,752KB
  • 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
  • (8)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete