From 6b994d0938b491118660ea4e67087167ea68a6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 15 Jun 2026 15:45:58 +0400 Subject: [PATCH] =?UTF-8?q?v0.5.121:=20switchTo=20=D0=BF=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=20crud.list,=20=D0=B1=D0=B5=D0=B7=20save()=20=D0=B8=20?= =?UTF-8?q?=D0=B1=D0=B5=D0=B7=20impersonationCompanyId?= 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/user/index.js | 31 +++++++++++++++---------------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index a88dcb1..ddb5729 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.5.120", + "version": "0.5.121", "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 fb8476c..31139ff 100644 --- a/v2/src/config/index.js +++ b/v2/src/config/index.js @@ -9,7 +9,7 @@ // ═══════════════════════════════════════════════════════════════════════════════ module.exports = { - version: '0.5.120', + version: '0.5.121', // ── IAM ────────────────────────────────────────────────────────────────── iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user', diff --git a/v2/src/user/index.js b/v2/src/user/index.js index e150f9a..fd00256 100644 --- a/v2/src/user/index.js +++ b/v2/src/user/index.js @@ -28,22 +28,6 @@ function createUserRouter() { const isAdmin = req.canAdmin; const clId = req.clientId; - // ── Переключение компании ────────────────────────────────────── - if (req.query.switchTo) { - const targetId = req.query.switchTo; - if (isAdmin) { - req.session.user.activeClientId = targetId; - if (req.session.user.isImpersonated) req.session.user.impersonatedCompanyId = targetId; - return res.redirect('/v2/app'); - } else { - const allowed = (req.profiles || []).find(p => p.client_id === targetId); - if (allowed) { - req.session.user.activeClientId = targetId; - return res.redirect('/v2/app'); - } - } - } - // ── Компании для dropdown ─────────────────────────────────────── let companies; if (isAdmin) { @@ -69,6 +53,21 @@ function createUserRouter() { const includeDeleted = req.query.deleted === '1'; const { entries, used, limit } = await crud.list(clId, includeDeleted); + // ── Переключение компании ────────────────────────────────────── + if (req.query.switchTo) { + const targetId = req.query.switchTo; + if (isAdmin) { + req.session.user.activeClientId = targetId; + return res.redirect('/v2/app'); + } else { + const allowed = (req.profiles || []).find(p => p.client_id === targetId); + if (allowed) { + req.session.user.activeClientId = targetId; + return res.redirect('/v2/app'); + } + } + } + // ── Данные пользователя для шаблона ──────────────────────────── const sessionUser = req.session && req.session.user ? req.session.user : {}; const templateUser = {