Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2020-04-20 05:27:54

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Login by USERNAME or EMAIL

Hello, I introduced a simple change in login.php
allows the user to enter with USERNAME or EMAIL
add line and coment or remplace LINE 32 in original login.php
    # add lines mod login for email or username
    if (strpbrk($form_username, '@')){$campo ='email';}else {$campo ='username';}
    $username_sql = ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') ? $campo.'=\''.$db->escape($form_username).'\'' : 'LOWER(username)=LOWER(\''.$db->escape($form_username).'\')';
    #fin mod raffarraffa
    /* original lines
    $username_sql = ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') ? 'username=\''.$db->escape($form_username).'\'' : 'LOWER(username)=LOWER(\''.$db->escape($form_username).'\')';
    */

Offline

#2 2020-04-20 05:59:04

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 1,330
Website

Re: Login by USERNAME or EMAIL

Use the CODE bb-code for post design.

replace

LOWER(username)

to

LOWER('.$campo.')

Offline

#3 2020-04-20 08:40:05

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

Visman wrote:

Use the CODE bb-code for post design.

thanks, I didn't know how to use bbcode
Because I would like to change the field:

LOWER(username)

a

LOWER('.$campo.')
# add lines mod login para correo electrónico o nombre de usuario
    if (strpbrk ($ form_username ' @ ')) {$ campo =' email ';} else {$ campo =' username ';}
    $ username_sql = ($ db_type ==' mysql '|| $ db_type ==' mysqli '|| $ db_type ==' mysql_innodb '|| $ db_type ==' mysqli_innodb ')? $ campo. '= \' '. $ db-> escape ($ form_username).' \ '': 'LOWER (username) = LOWER (\' '. $ db-> escape ($ form_username).' \ ') ';
    /

You must also expand the username input.
line 246 of login.php (original)
i used

<label class="conl required"><strong><?php echo $lang_common['Username'] ?> <span><?php echo $lang_common['Required'] ?></span></strong><br /><input type="text" name="req_username" value="<?php if (isset($_POST['req_username'])) echo pun_htmlspecialchars($_POST['req_username']); ?>" size="45" maxlength="200" tabindex="1" /><br /></label>

Offline

#4 2020-04-29 19:37:30

macadoum
Member
From: Lyon
Registered: 2019-02-12
Posts: 24

Re: Login by USERNAME or EMAIL

Not sure if I do things well but after installing this, I cannot logging anymore. Blank page. Even restoring previous login.php didn't change anything. It probably break something in the database.

Offline

#5 2020-04-29 22:44:42

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

macadoum wrote:

Not sure if I do things well but after installing this, I cannot logging anymore. Blank page. Even restoring previous login.php didn't change anything. It probably break something in the database.

Hello, the modification does not make any changes in the database, it only verifies if the user  entered a name or an email (verifies there is @)
if you have a @ search for 'email, if they have a name search for' usename '...
only test in version 1.5.11

what version do you use

ps: sorry no speak english, use google traslator

Offline

#6 2020-04-30 07:49:41

macadoum
Member
From: Lyon
Registered: 2019-02-12
Posts: 24

Re: Login by USERNAME or EMAIL

I use version 1.5.11 too, (with Visman additions). But in my test fluxbb, after login, I get a blank page.

Offline

#7 2020-04-30 10:25:58

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

macadoum wrote:

I use version 1.5.11 too, (with Visman additions). But in my test fluxbb, after login, I get a blank page.

did you introduce any additional plugin or mod?
the login modification does nothing about the DB.
you cannot break your database.

Offline

#8 2020-04-30 10:31:29

macadoum
Member
From: Lyon
Registered: 2019-02-12
Posts: 24

Re: Login by USERNAME or EMAIL

Okay, it's probably not the database. However, the blank page after login is real.

Offline

#9 2020-04-30 10:40:39

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

If you use the backup login.php of your original installation, does the problem persist? Then it is not the modification of login.php that affects your installation.
let's see if i can help

Offline

#10 2020-04-30 10:42:29

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

macadoum wrote:

I use version 1.5.11 too, (with Visman additions).

use the "login.php "de Visman ?

Offline

#11 2020-05-02 12:31:36

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 1,330
Website

Re: Login by USERNAME or EMAIL

These users will receive login problems
https://fluxbb.org/forums/userlist.php? … rch=Submit

Offline

#12 2020-05-03 06:21:16

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

Visman wrote:

These users will receive login problems
https://fluxbb.org/forums/userlist.php? … rch=Submit

yes, users with @ or email address as username will have problems
see new version 1.1.2

Offline

#13 2020-05-22 08:38:33

tuia
Member
From: Lisbon
Registered: 2014-09-18
Posts: 18

Re: Login by USERNAME or EMAIL

Thank you for your modification, it is good and simple. But, what happens if there is more than 1 username registered with the same email address? Which username will it pick when logging in with the email address?

Offline

#14 2020-05-22 11:01:28

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

tuia wrote:

Thank you for your modification, it is good and simple. But, what happens if there is more than 1 username registered with the same email address? Which username will it pick when logging in with the email address?

You shouldn't have users with repeated emails. Not in Fluxbb 1.5.11.
If you want to register with existing email you would get this error

The following errors need to be corrected before you can register:
Someone else is already registered with that email address. Please choose another email address.

anyway if you have users with the same email would get an error because it would compare the password against the first matching email record.

Login error
The following error needs to be corrected before you can login:
Wrong username and/or password.

if you. you have repeated emails I can make a modification that allows login with the repeated email, but this would lower the security of the site

sorry no speak english, i am use google traslator

Offline

#15 2020-05-24 12:26:04

raffarraffa
Member
From: Argentina
Registered: 2020-04-20
Posts: 11

Re: Login by USERNAME or EMAIL

tuia wrote:

Thank you for your modification, it is good and simple. But, what happens if there is more than 1 username registered with the same email address? Which username will it pick when logging in with the email address?

thinking .....
You cannot have the same email with different users.
Not in fluxbb 1.5.11

How to recover the password?

https://fluxbb.org/forums/login.php?action=forget

Offline

Board footer

Powered by FluxBB