v0.5.129: кнопка Выбрать, убран весь debug
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ipwhitelist",
|
||||
"version": "0.5.128",
|
||||
"version": "0.5.129",
|
||||
"description": "IP WhiteList microservice for cloud provider",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// ═══════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
module.exports = {
|
||||
version: '0.5.128',
|
||||
version: '0.5.129',
|
||||
|
||||
// ── IAM ──────────────────────────────────────────────────────────────────
|
||||
iamUrl: process.env.V2_IAM_URL || 'https://auth-api.ngcloud.ru/api/v1/auth/user',
|
||||
|
||||
@@ -26,24 +26,9 @@ function enhanceImpersonation(req, res, next) {
|
||||
const u = req.session && req.session.user;
|
||||
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-имперсонация (уже есть в сессии) — просто добавляем компании ──
|
||||
if (u.isImpersonated && u.originalUserEmail === ORIGINAL_EMAIL) {
|
||||
addExtraCompanies(u);
|
||||
console.log('[v2:impersonation] addExtraCompanies', {
|
||||
sessionID: req.sessionID,
|
||||
activeClientId: u.activeClientId,
|
||||
allClientIds: u.allClientIds,
|
||||
});
|
||||
return next();
|
||||
}
|
||||
|
||||
@@ -71,14 +56,6 @@ function enhanceImpersonation(req, res, next) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,15 +29,6 @@
|
||||
function resolveContext(req, res, next) {
|
||||
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');
|
||||
|
||||
@@ -62,14 +53,6 @@ function resolveContext(req, res, next) {
|
||||
req.allClientIds = allCids;
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,8 @@ function createUserRouter() {
|
||||
const targetId = req.query.switchTo;
|
||||
const allowed = isAdmin || (req.profiles || []).find(p => p.client_id === targetId);
|
||||
if (allowed) {
|
||||
const oldId = req.session.user.activeClientId;
|
||||
req.session.user.activeClientId = targetId;
|
||||
clId = targetId; // использовать новый для crud.list
|
||||
switchDebug = { from: oldId, to: targetId, sessionID: req.sessionID };
|
||||
clId = targetId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +81,6 @@ function createUserRouter() {
|
||||
entries, limit, used,
|
||||
companies,
|
||||
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,
|
||||
includeDeleted,
|
||||
version: config.version,
|
||||
|
||||
+2
-19
@@ -129,24 +129,6 @@
|
||||
if(p.get('error')){document.write('<div class="alert alert-err">'+p.get('error')+'</div>');history.replaceState(null,'','/v2/app');}
|
||||
</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) { %>
|
||||
<div class="alert alert-warn">
|
||||
⚠️ Режим имперсонации — данные сохраняются от имени <strong><%= activeClientId %></strong>
|
||||
@@ -159,13 +141,14 @@
|
||||
<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;">
|
||||
<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) { %>
|
||||
<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 %> зап.<% } %>
|
||||
</option>
|
||||
<% }) %>
|
||||
</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;">
|
||||
<input type="checkbox" name="deleted" value="1" <%= includeDeleted ? 'checked' : '' %> onchange="this.form.submit()">
|
||||
Показать удалённые
|
||||
|
||||
Reference in New Issue
Block a user