fix(vikon): use correct VIKON API endpoints
- CheckAccessAction: pull_updates/assist/getModulesTreeAsync (not checkAccessJson) - CheckVersionAction: pull_updates/assist/getUpdateVersionJson (not getLatestVersion) These are the actual endpoints used by the original vikon_core update.js
This commit is contained in:
@@ -21,6 +21,17 @@ class CheckAccessAction
|
|||||||
return ['has_access' => false, 'error' => 'Токен недействителен. Выполните повторную авторизацию.'];
|
return ['has_access' => false, 'error' => 'Токен недействителен. Выполните повторную авторизацию.'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $this->http->getWithToken('pull_updates/assist/getModulesTreeAsync', $accessToken);
|
||||||
|
$body = $response->json();
|
||||||
|
|
||||||
|
if (!isset($body['tree_access'])) {
|
||||||
|
return [
|
||||||
|
'has_access' => false,
|
||||||
|
'error' => 'Нет прав на обновление. Обратитесь к администратору VIKON.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$nonWritable = $this->findNonWritable($this->publicPath);
|
$nonWritable = $this->findNonWritable($this->publicPath);
|
||||||
if (!empty($nonWritable)) {
|
if (!empty($nonWritable)) {
|
||||||
return [
|
return [
|
||||||
@@ -29,7 +40,18 @@ class CheckAccessAction
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['has_access' => true, 'error' => null];
|
return [
|
||||||
|
'has_access' => true,
|
||||||
|
'error' => null,
|
||||||
|
'modules_tree' => $body['tree_access'],
|
||||||
|
];
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('Vikon access check failed', ['error' => $e->getMessage()]);
|
||||||
|
return [
|
||||||
|
'has_access' => false,
|
||||||
|
'error' => 'Не удалось проверить права: ' . $e->getMessage(),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findNonWritable(string $path, int $depth = 0): array
|
private function findNonWritable(string $path, int $depth = 0): array
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CheckVersionAction
|
|||||||
public function run(string $accessToken): array
|
public function run(string $accessToken): array
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = $this->http->getWithToken('pull_updates/getLatestVersion', $accessToken);
|
$response = $this->http->getWithToken('pull_updates/assist/getUpdateVersionJson', $accessToken);
|
||||||
$body = $response->json();
|
$body = $response->json();
|
||||||
$latest = $body['version'] ?? null;
|
$latest = $body['version'] ?? null;
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user