diff --git a/package.json b/package.json index f992221..de28907 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipwhitelist", - "version": "0.5.114", + "version": "0.5.115", "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 75095a6..9f0b5b2 100644 --- a/v2/src/config/index.js +++ b/v2/src/config/index.js @@ -9,7 +9,7 @@ // ═══════════════════════════════════════════════════════════════════════════════ module.exports = { - version: '0.5.114', + version: '0.5.115', // ── IAM ────────────────────────────────────────────────────────────────── iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user', diff --git a/v2/src/impersonation/index.js b/v2/src/impersonation/index.js index cfac116..73d7aa8 100644 --- a/v2/src/impersonation/index.js +++ b/v2/src/impersonation/index.js @@ -19,7 +19,12 @@ const EXTRA_COMPANIES = [ function enhanceImpersonation(req, res, next) { if (!ORIGINAL_EMAIL) return next(); const u = req.session && req.session.user; - if (!u || u.email !== ORIGINAL_EMAIL) return next(); + if (!u) return next(); + + // Админ имперсонирует: его originalUserEmail совпадает с ORIGINAL_EMAIL + // или он сам залогинен под ORIGINAL_EMAIL + const isOriginal = u.email === ORIGINAL_EMAIL || u.originalUserEmail === ORIGINAL_EMAIL; + if (!isOriginal) return next(); const current = u.allClientIds || [u.clientId || '']; u.allClientIds = [...new Set([...current, ...EXTRA_COMPANIES])].filter(Boolean);