From 02abab93d77fbb2c1d314fbec9a9863cf48243fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 15 Jun 2026 15:26:36 +0400 Subject: [PATCH] =?UTF-8?q?v0.5.118:=20=D1=84=D0=B8=D0=BA=D1=81=20=D1=81?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=B8=D0=BC=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=81=D0=BE=D0=BD=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- v2/src/config/index.js | 2 +- v2/src/router/index.js | 5 ++++- v2/src/user/index.js | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d2bc87c..ec75f84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.5.117", + "version": "0.5.118", "description": "IP WhiteList microservice for cloud provider", "main": "server.js", "scripts": { diff --git a/v2/src/config/index.js b/v2/src/config/index.js index 07f5975..6f25835 100644 --- a/v2/src/config/index.js +++ b/v2/src/config/index.js @@ -9,7 +9,7 @@ // ═══════════════════════════════════════════════════════════════════════════════ module.exports = { - version: '0.5.117', + version: '0.5.118', // ── IAM ────────────────────────────────────────────────────────────────── iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user', diff --git a/v2/src/router/index.js b/v2/src/router/index.js index 3545b7d..0864fd6 100644 --- a/v2/src/router/index.js +++ b/v2/src/router/index.js @@ -38,7 +38,10 @@ function resolveContext(req, res, next) { const isImpersonated = !!(u.originalUserEmail && u.impersonatedCompanyId); req.email = u.email || ''; - req.clientId = isImpersonated ? u.impersonatedCompanyId : (u.activeClientId || u.clientId || ''); + // activeClientId может переопределять impersonatedCompanyId при switchTo + req.clientId = isImpersonated + ? (u.activeClientId || u.impersonatedCompanyId || u.clientId || '') + : (u.activeClientId || u.clientId || ''); req.companyName = u.companyName || req.clientId; // Админ: пользователь с WZ01112 — всегда админ const allCids = u.allClientIds || [u.clientId || '']; diff --git a/v2/src/user/index.js b/v2/src/user/index.js index 46f3b86..29434f3 100644 --- a/v2/src/user/index.js +++ b/v2/src/user/index.js @@ -34,6 +34,7 @@ function createUserRouter() { if (isAdmin) { // Админ может переключиться на любую компанию req.session.user.activeClientId = targetId; + if (req.session.user.isImpersonated) req.session.user.impersonatedCompanyId = targetId; req.session.save(() => res.redirect('/v2/app')); return; } else {