v0.5.115: имперсонация проверяет originalUserEmail, компании добавляются имперсонируемому

This commit is contained in:
“Naeel”
2026-06-15 14:47:38 +04:00
parent 3c9fadca6a
commit 561c5f1ba7
2 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -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": {
+6 -1
View File
@@ -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);