v2: fix switch case in test API (был сломан sed-ом)

This commit is contained in:
2026-06-12 22:29:24 +04:00
parent e7f0611947
commit 23c59c1aae
3 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ipwhitelist",
"version": "0.5.83",
"version": "0.5.84",
"description": "IP WhiteList microservice for cloud provider",
"main": "server.js",
"scripts": {
+1 -1
View File
@@ -6,7 +6,7 @@
// ═══════════════════════════════════════════════════════════════════════════════
module.exports = {
version: '0.5.83',
version: '0.5.84',
iamUrl: process.env.V2_IAM_API_URL || 'https://auth-api.ngcloud.ru',
appUrl: process.env.V2_APP_URL || 'https://whitelist.nodejsk8s.services.ngcloud.ru',
};
+11
View File
@@ -61,6 +61,17 @@ function createTestRouter() {
case 'limit':
return res.json({ ok: true, limit: await q.getLimit(company) });
// ── SWITCH ──
case 'switch': {
const to = req.query.to;
if (!to) return res.json({ ok: false, error: 'no to parameter' });
if (!user.allClientIds.includes(to)) return res.json({ ok: false, error: 'not in allClientIds' });
user.activeClientId = to;
const p = user.profiles.find(p => p.client_id === to);
if (p) { p.is_active_profile = true; user.profiles.forEach(x => { if (x !== p) x.is_active_profile = false; }); }
return res.json({ ok: true, switchedTo: to });
}
// ── CLEANUP ──
case 'cleanup': {
const cids = (req.query.cids || '').split(',');