From 1794610f77085075b279f40e6ca6f355e6c02a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 11 Jun 2026 11:18:59 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20ownCo=20not=20found=20=E2=86=92=20getOrC?= =?UTF-8?q?reateCompany=20instead=20of=20companies[0]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Убрал fallback на companies[0] — небезопасно - Если компания админа не найдена — создаём через getOrCreateCompany --- package.json | 2 +- ui/routes/entries.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 72c9f4c..ed0f5ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.5.39", + "version": "0.5.40", "description": "IP WhiteList microservice for cloud provider", "main": "server.js", "scripts": { diff --git a/ui/routes/entries.js b/ui/routes/entries.js index 08589a0..0d9ded2 100644 --- a/ui/routes/entries.js +++ b/ui/routes/entries.js @@ -85,7 +85,12 @@ function createRouter() { if (!companyId) { // Админ без ?company= — показываем свою компанию - const ownCo = companies.find(c => c.client_id === req.user.clientId) || companies[0]; + let ownCo = companies.find(c => c.client_id === req.user.clientId) || null; + if (!ownCo) { + await api.get('/api/v1/entries', token); // создаст компанию через getOrCreateCompany + const cr2 = await api.get('/api/v1/companies', token); + ownCo = (cr2.data.companies || []).find(c => c.client_id === req.user.clientId) || null; + } if (ownCo) { const includeDeleted = req.query.includeDeleted === 'true' ? '&includeDeleted=true' : ''; const er = await api.get('/api/v1/entries?company=' + ownCo.id + includeDeleted, token);