Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 06:20 pm EST
Geeklog Forums
Email address instead of username to login
Davidas
Anonymous
Is it possible to let users of your GL site login with their email address instead of their username ?
Which settings do I have to change ?
Let me know guys ...
Regards, David
Which settings do I have to change ?
Let me know guys ...
Regards, David
10
7
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
To start, you would need to change SEC_authenticate (in lib-security.php) to allow "username" to be an email address. Simplest way to do that is to assume any username with a '@' sign is an email. Then compare the value against the email field insted of the username field. Like this:
// replace $result = DB_query("SELECT ...." with
if (strchr($username,'@' !== FALSE) {
$sql = "SELECT .... WHERE email = '$username' and ...";
} else {
$sql = // the original sql statement
}
$result = DB_query($sql);
You might also change the text on the login template to "user name or email:"
That should get you 95% of it. I'm not sure what other gotchas there might be though so you would need to test it well.
// replace $result = DB_query("SELECT ...." with
if (strchr($username,'@' !== FALSE) {
$sql = "SELECT .... WHERE email = '$username' and ...";
} else {
$sql = // the original sql statement
}
$result = DB_query($sql);
You might also change the text on the login template to "user name or email:"
That should get you 95% of it. I'm not sure what other gotchas there might be though so you would need to test it well.
6
4
Quote
All times are EST. The time is now 06:20 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content