diff --git a/package.json b/package.json index fde38ef..869dcc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.4.5", + "version": "0.4.6", "description": "IP WhiteList microservice for cloud provider", "main": "server.js", "scripts": { diff --git a/ui/routes/entries.js b/ui/routes/entries.js index bdbe8b4..95e9380 100644 --- a/ui/routes/entries.js +++ b/ui/routes/entries.js @@ -48,11 +48,12 @@ function createRouter() { } if (companyParam === 'own') { - // Собственные записи admin (getOrCreateCompany внутри API) - const er = await api.get('/api/v1/entries', token); - entries = er.data.entries || []; - limit = er.data.limit || 15; - selectedCompany = { id: 'own', name: 'Моя компания', client_id: req.user.clientId }; + // Создаём/получаем компанию admin через API (getOrCreateCompany) + await api.get('/api/v1/entries', token); + // Перезагружаем список — теперь компания admin точно есть + const cr2 = await api.get('/api/v1/companies', token); + const adminCo = (cr2.data.companies || []).find(c => c.client_id === req.user.clientId); + return res.redirect('/?company=' + (adminCo ? adminCo.id : '')); } else { selectedCompany = companyId ? companies.find(c => c.id === companyId) || null : null; diff --git a/views/index.ejs b/views/index.ejs index 233004d..b63e5c0 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -176,7 +176,7 @@ // Для admin: selectedCompany — выбранная компания (объект из getAllCompanies). // Для обычного пользователя: selectedCompany — их компания (из getOrCreateCompany). // company_id — числовой PK для передачи в скрытые поля форм. - const companyPk = selectedCompany ? (selectedCompany.id === 'own' ? null : selectedCompany.id) : null; + const companyPk = selectedCompany ? selectedCompany.id : null; %> @@ -187,7 +187,6 @@ Компания: - → Аудит этой компании → Лимиты