v0.5.118: фикс смены компании при имперсонации
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ipwhitelist",
|
"name": "ipwhitelist",
|
||||||
"version": "0.5.117",
|
"version": "0.5.118",
|
||||||
"description": "IP WhiteList microservice for cloud provider",
|
"description": "IP WhiteList microservice for cloud provider",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
// ═══════════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
version: '0.5.117',
|
version: '0.5.118',
|
||||||
|
|
||||||
// ── IAM ──────────────────────────────────────────────────────────────────
|
// ── IAM ──────────────────────────────────────────────────────────────────
|
||||||
iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user',
|
iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user',
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ function resolveContext(req, res, next) {
|
|||||||
const isImpersonated = !!(u.originalUserEmail && u.impersonatedCompanyId);
|
const isImpersonated = !!(u.originalUserEmail && u.impersonatedCompanyId);
|
||||||
|
|
||||||
req.email = u.email || '';
|
req.email = u.email || '';
|
||||||
req.clientId = isImpersonated ? u.impersonatedCompanyId : (u.activeClientId || u.clientId || '');
|
// activeClientId может переопределять impersonatedCompanyId при switchTo
|
||||||
|
req.clientId = isImpersonated
|
||||||
|
? (u.activeClientId || u.impersonatedCompanyId || u.clientId || '')
|
||||||
|
: (u.activeClientId || u.clientId || '');
|
||||||
req.companyName = u.companyName || req.clientId;
|
req.companyName = u.companyName || req.clientId;
|
||||||
// Админ: пользователь с WZ01112 — всегда админ
|
// Админ: пользователь с WZ01112 — всегда админ
|
||||||
const allCids = u.allClientIds || [u.clientId || ''];
|
const allCids = u.allClientIds || [u.clientId || ''];
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ function createUserRouter() {
|
|||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
// Админ может переключиться на любую компанию
|
// Админ может переключиться на любую компанию
|
||||||
req.session.user.activeClientId = targetId;
|
req.session.user.activeClientId = targetId;
|
||||||
|
if (req.session.user.isImpersonated) req.session.user.impersonatedCompanyId = targetId;
|
||||||
req.session.save(() => res.redirect('/v2/app'));
|
req.session.save(() => res.redirect('/v2/app'));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user