X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fauthenticationplugin.php;h=66f11ca1a9507a5850bdb11418314b8407a39020;hb=b53e1439969bfa2c0b551d8cc2fc8fe15652c62a;hp=0a3763e2e4644d895095876acf13934393559f42;hpb=c1e96cbdefa66e66815c421378b9452d7c8d5548;p=quix0rs-gnu-social.git diff --git a/lib/authenticationplugin.php b/lib/authenticationplugin.php index 0a3763e2e4..66f11ca1a9 100644 --- a/lib/authenticationplugin.php +++ b/lib/authenticationplugin.php @@ -22,13 +22,12 @@ * @category Plugin * @package StatusNet * @author Craig Andrews + * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** * Superclass for plugins that do authentication @@ -39,12 +38,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - abstract class AuthenticationPlugin extends Plugin { //is this plugin authoritative for authentication? public $authoritative = false; - + //should accounts be automatically created after a successful login attempt? public $autoregistration = false; @@ -128,18 +126,18 @@ abstract class AuthenticationPlugin extends Plugin { if($provider_name == $this->provider_name && $this->autoregistration){ $suggested_nickname = $this->suggestNicknameForUsername($nickname); - $test_user = User::staticGet('nickname', $suggested_nickname); + $test_user = User::getKV('nickname', $suggested_nickname); if($test_user) { //someone already exists with the suggested nickname, so used the passed nickname $suggested_nickname = common_nicknamize($nickname); } - $test_user = User::staticGet('nickname', $suggested_nickname); + $test_user = User::getKV('nickname', $suggested_nickname); if($test_user) { //someone already exists with the suggested nickname //not much else we can do }else{ $user = $this->autoRegister($nickname, $suggested_nickname); - if($user){ + if ($user instanceof User) { User_username::register($user,$nickname,$this->provider_name); return false; } @@ -155,14 +153,14 @@ abstract class AuthenticationPlugin extends Plugin if($user_username->find() && $user_username->fetch()){ $authenticated = $this->checkPassword($user_username->username, $password); if($authenticated){ - $authenticatedUser = User::staticGet('id', $user_username->user_id); + $authenticatedUser = User::getKV('id', $user_username->user_id); return false; } }else{ //$nickname is the username used to login //$suggested_nickname is the nickname the auth provider suggests for that username $suggested_nickname = $this->suggestNicknameForUsername($nickname); - $user = User::staticGet('nickname', $suggested_nickname); + $user = User::getKV('nickname', $suggested_nickname); if($user){ //make sure this user isn't claimed $user_username = new User_username(); @@ -217,12 +215,14 @@ abstract class AuthenticationPlugin extends Plugin //stop handling of other handlers, because what was requested was done return false; }else{ - throw new Exception(_('Password changing failed')); + // TRANS: Exception thrown when a password change fails. + throw new Exception(_('Password changing failed.')); } }else{ if($this->authoritative){ //since we're authoritative, no other plugin could do this - throw new Exception(_('Password changing failed')); + // TRANS: Exception thrown when a password change fails. + throw new Exception(_('Password changing failed.')); }else{ //let another handler try return null; @@ -232,7 +232,8 @@ abstract class AuthenticationPlugin extends Plugin }else{ if($this->authoritative){ //since we're authoritative, no other plugin could do this - throw new Exception(_('Password changing is not allowed')); + // TRANS: Exception thrown when a password change attempt fails because it is not allowed. + throw new Exception(_('Password changing is not allowed.')); } } } @@ -247,16 +248,7 @@ abstract class AuthenticationPlugin extends Plugin function onCheckSchema() { $schema = Schema::get(); - $schema->ensureTable('user_username', - array(new ColumnDef('provider_name', 'varchar', - '255', false, 'PRI'), - new ColumnDef('username', 'varchar', - '255', false, 'PRI'), - new ColumnDef('user_id', 'integer', - null, false), - new ColumnDef('created', 'datetime', - null, false), - new ColumnDef('modified', 'timestamp'))); + $schema->ensureTable('user_username', User_username::schemaDef()); return true; } @@ -266,4 +258,3 @@ abstract class AuthenticationPlugin extends Plugin return true; } } -