From 030639d02d20937179ad24c24963c4d15479193e Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 28 Apr 2014 12:38:30 +0200 Subject: [PATCH] EmailAuthentication enabled by default The login field said "Username or email address" already, so... --- lib/default.php | 1 + .../EmailAuthenticationPlugin.php | 27 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/default.php b/lib/default.php index 8ac1fa8bbb..d2270fa6a5 100644 --- a/lib/default.php +++ b/lib/default.php @@ -301,6 +301,7 @@ $default = 'Activity' => array(), 'Bookmark' => array(), 'ClientSideShorten' => array(), + 'EmailAuthentication' => array(), 'Event' => array(), 'OpenID' => array(), 'Poll' => array(), diff --git a/plugins/EmailAuthentication/EmailAuthenticationPlugin.php b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php index eb2bebac65..a17748fe32 100644 --- a/plugins/EmailAuthentication/EmailAuthenticationPlugin.php +++ b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php @@ -27,27 +27,26 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } class EmailAuthenticationPlugin extends Plugin { - //---interface implementation---// + // $nickname for this plugin is the user's email address function onStartCheckPassword($nickname, $password, &$authenticatedUser) { - if(strpos($nickname, '@')) - { - $user = User::getKV('email',$nickname); - if($user && isset($user->email)) - { - if(common_check_user($user->nickname,$password)) - { - $authenticatedUser = $user; - return false; - } + if (!strpos($nickname, '@')) { + return true; + } + + $user = User::getKV('email', $nickname); + if ($user instanceof User && $user->email === $nickname) { + if (common_check_user($user->nickname, $password)) { + $authenticatedUser = $user; + return false; } } + + return true; } function onPluginVersion(&$versions)