v0.5.118: фикс смены компании при имперсонации
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
module.exports = {
|
||||
version: '0.5.117',
|
||||
version: '0.5.118',
|
||||
|
||||
// ── IAM ──────────────────────────────────────────────────────────────────
|
||||
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);
|
||||
|
||||
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;
|
||||
// Админ: пользователь с WZ01112 — всегда админ
|
||||
const allCids = u.allClientIds || [u.clientId || ''];
|
||||
|
||||
@@ -34,6 +34,7 @@ function createUserRouter() {
|
||||
if (isAdmin) {
|
||||
// Админ может переключиться на любую компанию
|
||||
req.session.user.activeClientId = targetId;
|
||||
if (req.session.user.isImpersonated) req.session.user.impersonatedCompanyId = targetId;
|
||||
req.session.save(() => res.redirect('/v2/app'));
|
||||
return;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user