]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/authenticationplugin.php
Avoid having to check for notices without rendered copies in upgrade.php
[quix0rs-gnu-social.git] / lib / authenticationplugin.php
index ad031e785240941a2516d7ed20c9af719ee0bfce..c33b0ef8a8b3dac054248cbb8390668482c41f87 100644 (file)
@@ -27,9 +27,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Superclass for plugins that do authentication
@@ -139,7 +137,7 @@ abstract class AuthenticationPlugin extends Plugin
                 //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;
                 }
@@ -203,13 +201,13 @@ abstract class AuthenticationPlugin extends Plugin
         }
     }
 
-    function onStartChangePassword($user,$oldpassword,$newpassword)
+    function onStartChangePassword(Profile $target ,$oldpassword, $newpassword)
     {
         if($this->password_changeable){
             $user_username = new User_username();
-            $user_username->user_id=$user->id;
+            $user_username->user_id = $target->getID();
             $user_username->provider_name=$this->provider_name;
-            if($user_username->find() && $user_username->fetch()){
+            if ($user_username->find(true)) {
                 $authenticated = $this->checkPassword($user_username->username, $oldpassword);
                 if($authenticated){
                     $result = $this->changePassword($user_username->username,$oldpassword,$newpassword);
@@ -250,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;
     }