Email login

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
tigaz
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Fri Dec 02, 2016 12:26 am

Email login

Post by tigaz » Fri Dec 02, 2016 10:52 am

Hi everybody

I hope this is the right place to ask.

I would like to use the default login form in Joomla 3.6.4 to login with email address and password. Could somebody help me on how to do that? I tried to change the "username" part in the where clause of the Joomla authentication plugin to "email":

This part:

Code: Select all

$db    = JFactory::getDbo();
$query = $db->getQuery(true)
	->select('id, password')
	->from('#__users')
	->where('username=' . $db->quote($credentials['username']));
I tried to change that to:

Code: Select all

$db    = JFactory::getDbo();
$query = $db->getQuery(true)
	->select('id, password')
	->from('#__users')
	->where('email=' . $db->quote($credentials['username']));
For some reason that's not enough. I still can't login with the email address.

I'm getting the error message:
Warning
You can't access the private section of this site.
Do I have to change anything else to make it work?

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3492
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Email login

Post by ribo » Fri Dec 02, 2016 10:47 pm

It s not good to change core files. Extend your joomla. Try something like this https://extensions.joomla.org/extension/awo-email-login
chat room spontes : http://www.spontes.com

tigaz
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Fri Dec 02, 2016 12:26 am

Re: Email login

Post by tigaz » Sat Dec 03, 2016 10:01 pm

Thanks for the link ribo. I'll try that and get back if it doesn't work.

I would never change core files. The plan was to clone the Joomla auth plugin and extend the functionality in the cloned plugin.

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 10420
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Email login

Post by sozzled » Sat Dec 03, 2016 10:22 pm

tigaz wrote:I would like to use the default login form in Joomla 3.6.4 to login with email address and password. Could somebody help me on how to do that?
I'm trying to undestand the requirement. Can we take it a little slower, please (I don't like to jump in with an answer before I know the depth of the issue).

Three questions (and these are all important):

1) Are these accounts already registered on your website in the form of username=myname@maildomain.xyz?

2) Is the target site (or, if the site is still under development, is it intended to be) available to the general public?

3) If the answer to (2) above is yes, are you aware that people generally do not want their email addresses displayed to others?
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)
Testing J! 3.10: https://sintranet.enduring.com.au

sovainfo
Joomla! Exemplar
Joomla! Exemplar
Posts: 8808
Joined: Sat Oct 01, 2011 7:06 pm

Re: Email login

Post by sovainfo » Sat Dec 03, 2016 10:56 pm

1) No, they are normal users
2) don't see the relevancy
3) also not relevant for the OP issue ( using email instead of username to authenticate )
Issue with migrating? Include logs/joomla_update.php in your report!
Blank screen? Verify pagesource for HTML code (javascript error)
Installation failing on populating database? Install with set_time_limit(0)
Document your customizations!

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3492
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Email login

Post by ribo » Sat Dec 03, 2016 11:05 pm

sovainfo wrote: ( using email instead of username to authenticate )
That is what OP wants to do, nothing less, nothing more.
chat room spontes : http://www.spontes.com

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 10420
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: Email login

Post by sozzled » Sun Dec 04, 2016 12:16 am

1) Technically-speaking, there should be no problem using Joomla (without any modification). If a person wants to register an account (with a username in the forum of user@maildomain.xyz) then these characters are allowable; I tested this on a "vanilla-flavoured" J 3.6.4 website, just to be sure.

2) Assuming the site is/will be available to the public.

3) User accounts that take the form of an email address are allowed. Some people may prefer to use a username that is not an "email address" (for example, "tigaz"). My questions, however, are
  1. Do you want to enforce a policy that restricts usernames to conform to an email address format?
  2. Do you want to validate an email address and then authenticate that user account to login to your website?
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?” :)
Testing J! 3.10: https://sintranet.enduring.com.au

tigaz
Joomla! Apprentice
Joomla! Apprentice
Posts: 36
Joined: Fri Dec 02, 2016 12:26 am

Re: Email login

Post by tigaz » Sun Dec 04, 2016 11:20 pm

Thank you for your in depth questions sozzled

Questions part 1
1) No they are not registered in that form but I could update them if needed
2) The target site is available for the general public
3) Yes but the email address will not be displayed to other users on the website

Questions part 2
1) I do not necessarily want to force users to enter an email address into the username field
2) I want the user to be able to login with both username and email address. The plugin ribo recommended actually fulfilled my needs. It allows both username and email login. The username is entered into the username field and the email is entered into the email field. Just what I was looking for.

User avatar
yop
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Sun Sep 21, 2008 6:47 pm
Location: Jakarta, Indonesia
Contact:

Re: Email login

Post by yop » Tue Apr 17, 2018 9:54 am

I hope this feature added as default on Joomla 4. Forcing people to remember username is really not necessary. Most people can only remember their email address to login...
Please read forum rules regarding signatures: http://forum.joomla.org/viewtopic.php?t=65


Locked

Return to “Joomla! 3.x Coding”