Joomla-cms: [4.0] Email as user login.

Created on 3 Jun 2020  路  10Comments  路  Source: joomla/joomla-cms

Is your feature request related to a problem? Please describe.

It is time for users to be able to LOGIN with their email natively, since it has been the trend for more than 10 years and in joomla it is still limited to using a username.

Describe the solution you'd like

Additional context

New Feature No Code Attached Yet

Most helpful comment

use a plugin. they already exist to do what you want. no need to replicate it

here https://extensions.joomla.org/tags/email-authentication/ there are 4 plugins that does this: one has 0.5 stars, the one with 5 stars does not handle registration, the third is now unsupported and the last one was last updated on august 2018.
I think this should be in the CMS out of the box, and would be a great plus. I would like to be a coder to try myself but i'm not skilled enough sadly, all i can do is suggest ways to improve joomla and make it easier for normal users/creators

All 10 comments

Well.. i'm more radical, i think we should eliminate the username completly, and just use the email/password combo.
Anyway about the login is easy to check mail or username... but what happens in a situation like this:

__USER A__
email: [email protected]
username: usera

__USER B__
email: [email protected]
username: [email protected]

Cattura

Not kind but now a user can do this.
If you setup a login form with "use username or email to login" and the user fill with:

[email protected]
password

do the system have to check [email protected] as a mail or as a password?

i think we should eliminate the username completly, and just use the email/password combo

Please don't take a dump on UX and privacy

There are many plugins available that will offer this if you want it on your site - no need to change core

i think we should eliminate the username completly, and just use the email/password combo

Please don't take a dump on UX and privacy

when registered users are "visible" in the website frontend (comments, users lists, and so on...) i agree with you. In all the other cases (like a ecommerce) where users are invisible each other just ask for email is a better user experience, as the user need to remember one easy thing only: his email.
Maybe a hybrid solution could be an on/off toggle in users settings like "use email as username", and when it's "on" the registration form shows only the email field and then fill the username filed with the email. So the username is still there but it's the same as the email

use a plugin. they already exist to do what you want. no need to replicate it

I think that this option should be in the CMS out of the box (without third-party plugins). I do not think that this will greatly complicate the CMS and make support very difficult. Now I have seen this on so many sites, forums and social networks, I have seen it almost everywhere.

Naturally, this should be optional, as a setting that can be turned on or off.

In fact, this is the standard of today for any site. I will even say more - even personal accounts of banks sometimes allow you to use an e-mail address, or a username, or a phone number to enter.

use a plugin. they already exist to do what you want. no need to replicate it

here https://extensions.joomla.org/tags/email-authentication/ there are 4 plugins that does this: one has 0.5 stars, the one with 5 stars does not handle registration, the third is now unsupported and the last one was last updated on august 2018.
I think this should be in the CMS out of the box, and would be a great plus. I would like to be a coder to try myself but i'm not skilled enough sadly, all i can do is suggest ways to improve joomla and make it easier for normal users/creators

Ok, here I am with some code.
I'm no coder, maybe what i've done is an heresy, but i'm doing my best to improve joomla as i love this project.

Purpose of the fix: let admins choose to use email as username or not

First step: insert the toggle in users config area

file: administrator/components/com_users/config.xml
just add:

<field
    name="emailAsUsername"
    type="radio"
    label="COM_USERS_CONFIG_FIELD_EMAILASUSERNAME_LABEL"
    layout="joomla.form.field.radio.switcher"
    default="0"
    showon="allowUserRegistration:1">
    <option value="0">JNO</option>
    <option value="1">JYES</option>
</field>

2nd step: add language override

COM_USERS_CONFIG_FIELD_EMAILASUSERNAME_LABEL

3d step: modify the Model

in file components/com_users/src/Model/RegistrationModel.php
on line 382, just add

if (ComponentHelper::getParams('com_users')->get('emailAsUsername') == 1)
        {
            $form->removeField('username');
        }

4th step: Modify the Table library

in file components/libraries/src/Table/User.php
on line 23 add:

use Joomla\CMS\Component\ComponentHelper;

then delete from line 220 to 233

then on line ~229 (before "//Convert email to punycode..") add

if (ComponentHelper::getParams('com_users')->get('emailAsUsername') == 0)
        {
                if ($filterInput->clean($this->username, 'TRIM') == '')
            {
                $this->setError(Text::_('JLIB_DATABASE_ERROR_PLEASE_ENTER_A_USER_NAME'));

                return false;
            }

            if (preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $this->username) || StringHelper::strlen($this->username) < 2
                || $filterInput->clean($this->username, 'TRIM') !== $this->username || StringHelper::strlen($this->username) > 150)
            {
                $this->setError(Text::sprintf('JLIB_DATABASE_ERROR_VALID_AZ09', 2));

                return false;
            }
        } else {
            $this->username = $this->email;
        }

If everything is correct and i did not made any mistake pasting the code you will have a new user option:

immagine

and in frontend the registration form will be like this:

immagine

If you register you will have the new user with email as the username:

immagine

Can this be a start? Hope i did not screw up too much with joomla core files, let me know what you think!

use a plugin. they already exist to do what you want. no need to replicate it

This comment again shows the problem that Joomla has:

Be critical of what's new, use outdated design that is intended for programmers rather than end users.

The view of some developers should change fundamentally if Joomla wants to keep up on the market.

Please continue discussion in #29471 to keep it under one issue. Thank you.

Was this page helpful?
0 / 5 - 0 ratings