X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2FEmailAuthentication%2FEmailAuthenticationPlugin.php;h=a17748fe3208d66286ddaa4de44f25fb161966a1;hb=5bea746fa81d70335717f592fadb80f3892f7d73;hp=4c018537b87f2b14f020ad45fd9ca667ad5e9a7e;hpb=7f3b3620af2af88ced37da1d9f8913cfd1a31b90;p=quix0rs-gnu-social.git diff --git a/plugins/EmailAuthentication/EmailAuthenticationPlugin.php b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php index 4c018537b8..a17748fe32 100644 --- a/plugins/EmailAuthentication/EmailAuthenticationPlugin.php +++ b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php @@ -27,39 +27,37 @@ * @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::staticGet('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) { $versions[] = array('name' => 'Email Authentication', - 'version' => STATUSNET_VERSION, + 'version' => GNUSOCIAL_VERSION, 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:EmailAuthentication', 'rawdescription' => + // TRANS: Plugin description. _m('The Email Authentication plugin allows users to login using their email address.')); return true; } } -