-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- remove existing x-csrf-token headers before adding a new one, UniFi OS does not like multiple x-csrf-tokens in the same request
- Loading branch information
1 parent
007117c
commit d36a088
Showing
1 changed file
with
11 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* | ||
* @package UniFi_Controller_API_Client_Class | ||
* @author Art of WiFi <[email protected]> | ||
* @version Release: 1.1.89 | ||
* @version Release: 1.1.90 | ||
* @license This class is subject to the MIT license that is bundled with this package in the file LICENSE.md | ||
* @example This directory in the package repository contains a collection of examples: | ||
* https://github.com/Art-of-WiFi/UniFi-API-client/tree/master/examples | ||
|
@@ -25,7 +25,7 @@ class Client | |
* | ||
* NOTE: do **not** modify the values below, instead use the constructor or the getter and setter functions/methods | ||
*/ | ||
const CLASS_VERSION = '1.1.89'; | ||
const CLASS_VERSION = '1.1.90'; | ||
protected string $baseurl = 'https://127.0.0.1:8443'; | ||
protected string $user = ''; | ||
protected string $password = ''; | ||
|
@@ -4108,6 +4108,15 @@ protected function create_x_csrf_token_header() | |
return; | ||
} | ||
|
||
/** | ||
* remove any existing x-csrf-token headers first | ||
*/ | ||
foreach ($this->curl_headers as $index => $header) { | ||
if (strpos(strtolower($header), strtolower('x-csrf-token:')) !== false) { | ||
unset($this->curl_headers[$index]); | ||
} | ||
} | ||
|
||
$this->curl_headers[] = 'x-csrf-token: ' . json_decode(base64_decode($jwt_components[1]))->csrfToken; | ||
} | ||
} | ||
|