diff --git a/CHANGELOG.md b/CHANGELOG.md index cd68553d..e3f41707 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes +## 2.6.1 (2023-06-24) + +- Fix api token checking + ## 2.6.0 (2023-06-21) - Try to auto-generate meaningful linked content preview if display setting is missing diff --git a/bootstrap.php b/bootstrap.php index 16d60333..c8943a45 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,6 +1,6 @@ null ]; - if ($token != 'public') { + if ($token != 'public' && preg_match('/^USR-/', $token)) { - if (preg_match('/^USR-/', $token)) { + $user = $this->dataStorage->findOne('system/users', ['apiKey' => $token]); - $user = $this->dataStorage->findOne('system/users', ['apiKey' => $token]); - - if (!$user) { - $this->response->status = 412; - return ['error' => 'Authentication failed']; - } + if (!$user) { + $this->response->status = 412; + return ['error' => 'Authentication failed']; + } - $apiUser['user'] = $user['user']; - $apiUser['role'] = $user['role']; + $apiUser['user'] = $user['user']; + $apiUser['role'] = $user['role']; - // is jwt token? - } elseif (preg_match('/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/', $token)) { + // is jwt token? + } elseif ($token != 'public' && preg_match('/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/', $token)) { // todo - } - } else { $key = $this->helper('api')->getKey($token);