v0.5.129: кнопка Выбрать, убран весь debug

This commit is contained in:
2026-06-15 16:55:13 +04:00
parent b41af5649f
commit e440700a72
6 changed files with 5 additions and 69 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "ipwhitelist", "name": "ipwhitelist",
"version": "0.5.128", "version": "0.5.129",
"description": "IP WhiteList microservice for cloud provider", "description": "IP WhiteList microservice for cloud provider",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {
+1 -1
View File
@@ -9,7 +9,7 @@
// ═══════════════════════════════════════════════════════════════════════════════ // ═══════════════════════════════════════════════════════════════════════════════
module.exports = { module.exports = {
version: '0.5.128', version: '0.5.129',
// ── 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',
-23
View File
@@ -26,24 +26,9 @@ function enhanceImpersonation(req, res, next) {
const u = req.session && req.session.user; const u = req.session && req.session.user;
if (!u) return next(); if (!u) return next();
console.log('[v2:impersonation] enter', {
sessionID: req.sessionID,
email: u.email,
activeClientId: u.activeClientId,
clientId: u.clientId,
isImpersonated: u.isImpersonated,
originalUserEmail: u.originalUserEmail,
path: req.originalUrl,
});
// ── IAM-имперсонация (уже есть в сессии) — просто добавляем компании ── // ── IAM-имперсонация (уже есть в сессии) — просто добавляем компании ──
if (u.isImpersonated && u.originalUserEmail === ORIGINAL_EMAIL) { if (u.isImpersonated && u.originalUserEmail === ORIGINAL_EMAIL) {
addExtraCompanies(u); addExtraCompanies(u);
console.log('[v2:impersonation] addExtraCompanies', {
sessionID: req.sessionID,
activeClientId: u.activeClientId,
allClientIds: u.allClientIds,
});
return next(); return next();
} }
@@ -71,14 +56,6 @@ function enhanceImpersonation(req, res, next) {
is_active_profile: cid === MAIN_COMPANY, is_active_profile: cid === MAIN_COMPANY,
})); }));
console.log('[v2:impersonation] applied test impersonation', {
sessionID: req.sessionID,
activeClientId: u.activeClientId,
clientId: u.clientId,
originalUserEmail: u.originalUserEmail,
allClientIds: u.allClientIds,
});
return next(); return next();
} }
-17
View File
@@ -29,15 +29,6 @@
function resolveContext(req, res, next) { function resolveContext(req, res, next) {
const u = req.session && req.session.user; const u = req.session && req.session.user;
console.log('[v2:resolveContext] enter', {
sessionID: req.sessionID,
hasSession: !!req.session,
hasUser: !!u,
sessionActiveClientId: u ? u.activeClientId : null,
sessionClientId: u ? u.clientId : null,
url: req.originalUrl,
});
// Нет сессии — нет доступа // Нет сессии — нет доступа
if (!u) return res.redirect('/v2/login'); if (!u) return res.redirect('/v2/login');
@@ -62,14 +53,6 @@ function resolveContext(req, res, next) {
req.allClientIds = allCids; req.allClientIds = allCids;
req.profiles = u.profiles || []; req.profiles = u.profiles || [];
console.log('[v2:resolveContext] exit', {
sessionID: req.sessionID,
reqClientId: req.clientId,
reqEmail: req.email,
canAdmin: req.canAdmin,
isImpersonated: req.isImpersonated,
});
next(); next();
} }
+1 -8
View File
@@ -55,10 +55,8 @@ function createUserRouter() {
const targetId = req.query.switchTo; const targetId = req.query.switchTo;
const allowed = isAdmin || (req.profiles || []).find(p => p.client_id === targetId); const allowed = isAdmin || (req.profiles || []).find(p => p.client_id === targetId);
if (allowed) { if (allowed) {
const oldId = req.session.user.activeClientId;
req.session.user.activeClientId = targetId; req.session.user.activeClientId = targetId;
clId = targetId; // использовать новый для crud.list clId = targetId;
switchDebug = { from: oldId, to: targetId, sessionID: req.sessionID };
} }
} }
@@ -83,11 +81,6 @@ function createUserRouter() {
entries, limit, used, entries, limit, used,
companies, companies,
activeClientId: clId, activeClientId: clId,
debugClientId: clId,
sessionId: req.sessionID || '',
sessionActiveClientId: req.session && req.session.user ? (req.session.user.activeClientId || '') : '',
sessionClientId: req.session && req.session.user ? (req.session.user.clientId || '') : '',
switchDebug,
user: templateUser, user: templateUser,
includeDeleted, includeDeleted,
version: config.version, version: config.version,
+2 -19
View File
@@ -129,24 +129,6 @@
if(p.get('error')){document.write('<div class="alert alert-err">'+p.get('error')+'</div>');history.replaceState(null,'','/v2/app');} if(p.get('error')){document.write('<div class="alert alert-err">'+p.get('error')+'</div>');history.replaceState(null,'','/v2/app');}
</script> </script>
<div class="card" style="margin-bottom:1rem;border-style:dashed;">
<div class="card-body" style="font-size:.85rem;color:var(--muted);">
<div><strong>DEBUG</strong></div>
<div>sessionID: <%= (typeof sessionId !== 'undefined' && sessionId) ? sessionId : 'n/a' %></div>
<div>session.activeClientId: <%= (typeof sessionActiveClientId !== 'undefined' && sessionActiveClientId) ? sessionActiveClientId : 'n/a' %></div>
<div>req.clientId: <%= (typeof debugClientId !== 'undefined' && debugClientId) ? debugClientId : activeClientId %></div>
<div>req.session.user.clientId: <%= (typeof sessionClientId !== 'undefined' && sessionClientId) ? sessionClientId : 'n/a' %></div>
</div>
</div>
<% if (typeof switchDebug !== 'undefined' && switchDebug) { %>
<div style="background:#fff3cd;border:2px solid #d97706;color:#92400e;padding:.5rem 1rem;border-radius:8px;margin-bottom:.5rem;font-size:.85rem;">
<strong>DEBUG SWITCH:</strong> <%= switchDebug.from %> → <%= switchDebug.to %>
| sessionID: <%= switchDebug.sessionID %>
| activeClientId: <%= activeClientId %>
</div>
<% } %>
<% if (user.isImpersonated) { %> <% if (user.isImpersonated) { %>
<div class="alert alert-warn"> <div class="alert alert-warn">
⚠️ Режим имперсонации — данные сохраняются от имени <strong><%= activeClientId %></strong> ⚠️ Режим имперсонации — данные сохраняются от имени <strong><%= activeClientId %></strong>
@@ -159,13 +141,14 @@
<div class="card-body" style="padding:.75rem 1rem;"> <div class="card-body" style="padding:.75rem 1rem;">
<form method="GET" action="/v2/app" style="display:flex;align-items:center;gap:1rem;flex-wrap:wrap;"> <form method="GET" action="/v2/app" style="display:flex;align-items:center;gap:1rem;flex-wrap:wrap;">
<span style="font-size:.85rem;color:var(--muted);font-weight:500;">Компания:</span> <span style="font-size:.85rem;color:var(--muted);font-weight:500;">Компания:</span>
<select name="switchTo" onchange="this.form.submit()"> <select name="switchTo">
<% companies.forEach(function(c) { %> <% companies.forEach(function(c) { %>
<option value="<%= c.client_id %>" <%= c.client_id === activeClientId ? 'selected' : '' %>> <option value="<%= c.client_id %>" <%= c.client_id === activeClientId ? 'selected' : '' %>>
<%= c.name %> (<%= c.client_id %>)<% if (c.isPersonal) { %> (личное)<% } %><% if (c.active_count != null) { %> — <%= c.active_count %> зап.<% } %> <%= c.name %> (<%= c.client_id %>)<% if (c.isPersonal) { %> (личное)<% } %><% if (c.active_count != null) { %> — <%= c.active_count %> зап.<% } %>
</option> </option>
<% }) %> <% }) %>
</select> </select>
<button class="btn btn-sm btn-primary">Выбрать</button>
<label style="font-size:.82rem;color:var(--muted);cursor:pointer;display:flex;align-items:center;gap:.3rem;"> <label style="font-size:.82rem;color:var(--muted);cursor:pointer;display:flex;align-items:center;gap:.3rem;">
<input type="checkbox" name="deleted" value="1" <%= includeDeleted ? 'checked' : '' %> onchange="this.form.submit()"> <input type="checkbox" name="deleted" value="1" <%= includeDeleted ? 'checked' : '' %> onchange="this.form.submit()">
Показать удалённые Показать удалённые