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