Revert "v0.5.121: clientId всегда activeClientId || clientId, без спецлогики"
This reverts commit 1b043713a9.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ipwhitelist",
|
"name": "ipwhitelist",
|
||||||
"version": "0.5.121",
|
"version": "0.5.120",
|
||||||
"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.121',
|
version: '0.5.120',
|
||||||
|
|
||||||
// ── 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 = 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 || ''];
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ function createUserRouter() {
|
|||||||
const targetId = req.query.switchTo;
|
const targetId = req.query.switchTo;
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
req.session.user.activeClientId = targetId;
|
req.session.user.activeClientId = targetId;
|
||||||
|
if (req.session.user.isImpersonated) req.session.user.impersonatedCompanyId = targetId;
|
||||||
return res.redirect('/v2/app');
|
return res.redirect('/v2/app');
|
||||||
} else {
|
} else {
|
||||||
const allowed = (req.profiles || []).find(p => p.client_id === targetId);
|
const allowed = (req.profiles || []).find(p => p.client_id === targetId);
|
||||||
|
|||||||
Reference in New Issue
Block a user