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 |
Registered: 21 years ago Posts: 55 |
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
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
May 21, 2008 09:20AM |
Admin Registered: 18 years ago Posts: 8,532 |
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.
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.
(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.
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



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 |
Registered: 21 years ago Posts: 55 |
May 21, 2008 10:06AM |
Admin Registered: 18 years ago Posts: 8,532 |
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
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



Re: Module: Login with Email address May 21, 2008 11:08AM |
Registered: 15 years ago Posts: 35 |
Re: Module: Login with Email address May 21, 2008 11:09AM |
Registered: 21 years ago Posts: 55 |
Re: Module: Login with Email address May 21, 2008 11:12AM |
Registered: 15 years ago Posts: 35 |
Sorry, only registered users may post in this forum.