From 36e1afa6ae35890a26910951dec6dda98dcdee8f Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sat, 16 Oct 2010 20:38:27 -0700 Subject: [PATCH] allow login by username and multiple unique email addresses on system - this will provide support for group/celebrity pages (coming soon). --- README | 5 +---- include/auth.php | 3 ++- mod/register.php | 9 --------- mod/settings.php | 18 +++++++----------- view/login.tpl | 2 +- 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/README b/README index 36b7810bf..b4d51bd14 100644 --- a/README +++ b/README @@ -51,7 +51,4 @@ You may also contact the author and raise issues via the source code repository on github -- http://github.com/macgirvin/mistpark It's your network now. If social networking isn't what you thought it would -be, help us to make it better. - -Please support mistpark with a donation. - +be, help us to make it better. diff --git a/include/auth.php b/include/auth.php index 10d0df645..f4f75c607 100644 --- a/include/auth.php +++ b/include/auth.php @@ -66,7 +66,8 @@ else { // process login request $r = q("SELECT * FROM `user` - WHERE `email` = '%s' AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1", + WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1", + dbesc(trim($_POST['login-name'])), dbesc(trim($_POST['login-name'])), dbesc($encrypted)); if(($r === false) || (! count($r))) { diff --git a/mod/register.php b/mod/register.php index a2cae9961..890bc69b7 100644 --- a/mod/register.php +++ b/mod/register.php @@ -59,21 +59,12 @@ function register_post(&$a) { if(! preg_match("/^[a-zA-Z]* [a-zA-Z]*$/",$username)) $err .= t(' That doesn\'t appear to be your full name.'); - - $r = q("SELECT `uid` FROM `user` - WHERE `email` = '%s' LIMIT 1", - dbesc($email) - ); - if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}',$email)) $err .= t(' Not valid email.'); if(! allowed_email($email)) $err .= t(' Your email domain is not among those allowed on this site.'); - if($r !== false && count($r)) - $err .= t(' Your email address is already registered on this system.') ; - $nickname = strtolower($nickname); if(! preg_match("/^[a-z][a-z0-9\-\_]*$/",$nickname)) $err .= t(' Nickname must start with a letter and contain only letters, numbers, dashes, or underscore.') ; diff --git a/mod/settings.php b/mod/settings.php index cfd0df024..b76d9ffb9 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -81,28 +81,23 @@ function settings_post(&$a) { if(strlen($username) < 3) $err .= t(' Name too short.'); } + if($email != $a->user['email']) { $email_changed = true; if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}',$email)) $err .= t(' Not valid email.'); - $r = q("SELECT `uid` FROM `user` - WHERE `email` = '%s' LIMIT 1", - dbesc($email) - ); - if($r !== NULL && count($r)) - $err .= t(' This email address is already registered.'); } - if(strlen($err)) { - notice($err . EOL); - return; - } + if(strlen($err)) { + notice($err . EOL); + return; + } + if($timezone != $a->user['timezone']) { if(strlen($timezone)) date_default_timezone_set($timezone); } - $str_group_allow = perms2str($_POST['group_allow']); $str_contact_allow = perms2str($_POST['contact_allow']); $str_group_deny = perms2str($_POST['group_deny']); @@ -155,6 +150,7 @@ function settings_post(&$a) { if(! function_exists('settings_content')) { function settings_content(&$a) { + $o .= ''; if(! local_user()) { diff --git a/view/login.tpl b/view/login.tpl index c7cae1bb7..39fadb123 100644 --- a/view/login.tpl +++ b/view/login.tpl @@ -2,7 +2,7 @@
- +