Browse Source

Better test on specified user, when empty. Couldnt be null or false

Joachim M. Giæver 6 years ago
parent
commit
be5bcd6b6f
2 changed files with 4 additions and 4 deletions
  1. 3 3
      index.php
  2. 1 1
      src/API/Request/User.php

+ 3 - 3
index.php

@@ -12,14 +12,14 @@ require "./src/gpac.php";
 use Gogs\Lib\Curl\Exception as ApiException;
 
 define('API_URL', 'https://git.giaever.org/api/v1');
-//define('API_TOKEN', '142efbfd6fbdf147f03d289f8b22a438eaa1b5d1');
-define("API_TOKEN", 'e14b9eff0749b6f0c4cadf4bb72b83d44578ae');
+define('API_TOKEN', '142efbfd6fbdf147f03d289f8b22a438eaa1b5d1');
+//define("API_TOKEN", 'e14b9eff0749b6f0c4cadf4bb72b83d44578ae28');
 
 
 try {
     $client =  new Gogs\API\Client(API_URL, API_TOKEN);
 
-    $me = $client->user()->load();
+    $me = $client->user("")->load();
 
     $user_search = $client->users()->search(array(
         "name" => "tester2"

+ 1 - 1
src/API/Request/User.php

@@ -39,7 +39,7 @@ namespace Gogs\API\Request {
          * @param string $user The username. "Empty" or "me" will return authenticated user
          */
         public function __construct(string $api_url, string $api_token, string $user = "") {
-            $this->authenticated = (strlen($user) == 0 || $user == "me");
+            $this->authenticated = (empty($user) || $user == "me");
             parent::__construct($api_url, $api_token);
         }