Firefox PHP

Module: Login with Email address

Posted by johnwards 
All files from this thread

File Name File Size   Posted by Date  
email_auth.tar.gz 608 bytes open | download johnwards 05/21/2008 Read message
email_auth.zip 882 bytes open | download johnwards 05/21/2008 Read message
Module: Login with Email address
May 21, 2008 09:02AM
Hi Folks,

We have a requirement to let users login with their registered email address. This is due to porting legacy users over who are used to it but we don't really want them to be setting their username as their email address.

I have attached the mod that provides this functionality.

It is a simple mod and will let users login with usernames or emails.

Hope this is of some use to people.

Cheers
John
Attachments:
open | download - email_auth.tar.gz (608 bytes)
open | download - email_auth.zip (882 bytes)
Re: Module: Login with Email address
May 21, 2008 09:20AM
Funny. I was thinking about this kind of mod this morning. Must be the Phorum dev spider sense ;-)

I'd like to suggest to use the following kind of code for the check, to prevent the use of database queries in your module. By only using the user API, future compatibility and compatibility with other database layers is more secure. I did not actually test this code, but it should be at least almost ready for use.
function phorum_mod_email_login($data)
{
    // Check if we have a user for the provided username.
    $user_id = phorum_api_user_search('email', $data['username']);
    if (!$user_id) return $data;
    
    // Check if the password for this user matches the provided password.
    $user = phorum_api_user_get($user_id);
    if ($user && $user['password'] == md5($data['password'])) { 
        $data['user_id'] = $user_id;
    } 

    return $data;
}

Another suggestion is to add the following lines to the info.txt, so the module will show up in the module overview and will be version checked by Azumandias' module upgrade checker.
category: user_management
version: 1.0.0

(of course version 1.0.1 for your next release ;-)


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 1 time(s). Last edit at 05/21/2008 09:22AM by Maurice Makaay.
Re: Module: Login with Email address
May 21, 2008 09:32AM
Nice and a great change. I've edited the original thread and attached the new files and deleted the old ones. Not sure if this was the correct way of doing it.

Oh I love the module system!
Re: Module: Login with Email address
May 21, 2008 10:06AM
Me too ;-)

Replacing the files is the way to go, because the automatic module list building tool that Thomas wrote will only look at the first message in the thread to find module packages.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Login with Email address
May 21, 2008 11:08AM
Is there setting for this module in admin panel?

I install it and enabled but still log in with username.
Re: Module: Login with Email address
May 21, 2008 11:09AM
You can login with both email or username. It doesn't disable login with username.
Re: Module: Login with Email address
May 21, 2008 11:12AM
Oh sorry. I was trying to log in with my another email.
Sorry, only registered users may post in this forum.

Click here to login