From 68f230bedd1911486fef4420ad46303f98cbd981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 15 Jun 2026 10:28:06 +0400 Subject: [PATCH] =?UTF-8?q?v0.6.7:=20=D1=84=D0=B8=D0=BA=D1=81=20=E2=80=94?= =?UTF-8?q?=20req.email=3D=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B8=D0=B9,=20im?= =?UTF-8?q?personatedBy=3D=D1=80=D0=B5=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20(=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE)?= 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 | 10 +++++----- v2/src/user/index.js | 3 ++- views/v2/user.ejs | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 4348abd..dc7f580 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.6.6", + "version": "0.6.7", "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 b4c1221..a1470e4 100644 --- a/v2/src/config/index.js +++ b/v2/src/config/index.js @@ -9,7 +9,7 @@ // ═══════════════════════════════════════════════════════════════════════════════ module.exports = { - version: '0.6.6', + version: '0.6.7', // ── 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 31434d6..66692d7 100644 --- a/v2/src/router/index.js +++ b/v2/src/router/index.js @@ -38,15 +38,15 @@ function resolveContext(req, res, next) { const ADMIN_EMAIL = process.env.ADMIN_EMAIL || ''; const isImpersonated = !!(u.originalUserEmail && u.impersonatedCompanyId) || u.isImpersonated; - // req.email — для АУДИТА (реальный юзер при имперсонации) - req.email = isImpersonated ? u.originalUserEmail : (u.email || ''); - // req.displayEmail — для ПОКАЗА на экране (текущий, может быть имперсонированным) - req.displayEmail = u.email || ''; + // req.email = ТЕКУЩИЙ юзер (имперсонированный или реальный) + // ВЕЗДЕ: created_by, экран, формы + req.email = u.email || ''; req.clientId = isImpersonated ? u.impersonatedCompanyId : (u.activeClientId || u.clientId || ''); req.companyName = u.companyName || req.clientId; req.isAdmin = !!(u.isAdmin && u.adminMode) || (ADMIN_EMAIL && u.email === ADMIN_EMAIL); req.isImpersonated = isImpersonated; - req.impersonatedBy = isImpersonated ? u.email : null; + // req.impersonatedBy = РЕАЛЬНЫЙ юзер (только в колонке impersonated_by аудита) + req.impersonatedBy = isImpersonated ? (u.originalUserEmail || '') : null; req.allClientIds = u.allClientIds || [req.clientId]; req.profiles = u.profiles || []; diff --git a/v2/src/user/index.js b/v2/src/user/index.js index 6b558f3..c117815 100644 --- a/v2/src/user/index.js +++ b/v2/src/user/index.js @@ -43,7 +43,8 @@ function createUserRouter() { originalUserEmail: req.impersonatedBy ? req.email : null, email: req.email || (req.user && req.user.email) || (req.session && req.session.user && req.session.user.email) || '', loginEmail: (req.session && req.session.user && (req.session.user.originalUserEmail || req.session.user.email)) || req.email || '', - displayEmail: req.displayEmail || req.email || '', + email: req.email || '', + }); } catch (e) { res.status(500).send('

Ошибка

' + e.message + '
Назад'); diff --git a/views/v2/user.ejs b/views/v2/user.ejs index c91a63e..0647e1a 100644 --- a/views/v2/user.ejs +++ b/views/v2/user.ejs @@ -80,7 +80,7 @@ <% if (typeof isImpersonated !== 'undefined' && isImpersonated) { %> <% if (isImpersonated) { %>
- ⚠️ Режим имперсонации — данные сохраняются от имени <%= displayEmail %> + ⚠️ Режим имперсонации — данные сохраняются от имени <%= email %> (вы: <%= loginEmail %>)
<% } %> @@ -102,7 +102,7 @@
<%= used %>
из <%= limit %>
<%= activeClientId %> - <%= displayEmail %> + <%= email %>