]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Checking user properties for instanceof User
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 10 Nov 2014 10:57:53 +0000 (11:57 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 10 Nov 2014 10:57:53 +0000 (11:57 +0100)
lib/apiauthaction.php

index ed03820daa8df3fa17e1041e213ec57bb0ed48f9..683d42e7055d0d53fa2ab1b80335f938736c005c 100644 (file)
@@ -296,7 +296,7 @@ class ApiAuthAction extends ApiAction
 
             if (Event::handle('StartSetApiUser', array(&$user))) {
 
-                if (!empty($user)) {
+                if ($user instanceof User) {
                     if (!$user->hasRight(Right::API)) {
                         // TRANS: Authorization exception thrown when a user without API access tries to access the API.
                         throw new AuthorizationException(_('Not allowed to use API.'));
@@ -310,7 +310,7 @@ class ApiAuthAction extends ApiAction
             // By default, basic auth users have rw access
             $this->access = self::READ_WRITE;
 
-            if (empty($this->auth_user) && ($required || isset($_SERVER['PHP_AUTH_USER']))) {
+            if (!$this->auth_user instanceof User && ($required || isset($_SERVER['PHP_AUTH_USER']))) {
                 $msg = sprintf(
                     "basic auth nickname = %s",
                     $this->auth_user_nickname