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);