fix: cleanup files

This commit is contained in:
LukeGus
2025-12-19 21:11:15 -06:00
parent ab3d4c6abb
commit 1f0df349c7
4 changed files with 56 additions and 32 deletions
+28 -12
View File
@@ -14,7 +14,17 @@ import {
hostAccess, hostAccess,
userRoles, userRoles,
} from "../db/schema.js"; } from "../db/schema.js";
import { eq, and, desc, isNotNull, or, isNull, gte, sql, inArray } from "drizzle-orm"; import {
eq,
and,
desc,
isNotNull,
or,
isNull,
gte,
sql,
inArray,
} from "drizzle-orm";
import type { Request, Response } from "express"; import type { Request, Response } from "express";
import multer from "multer"; import multer from "multer";
import { sshLogger } from "../../utils/logger.js"; import { sshLogger } from "../../utils/logger.js";
@@ -253,6 +263,7 @@ router.post(
socks5Username, socks5Username,
socks5Password, socks5Password,
socks5ProxyChain, socks5ProxyChain,
overrideCredentialUsername,
} = hostData; } = hostData;
console.log("POST /db/ssh - Received SOCKS5 data:", { console.log("POST /db/ssh - Received SOCKS5 data:", {
@@ -287,6 +298,7 @@ router.post(
username, username,
authType: effectiveAuthType, authType: effectiveAuthType,
credentialId: credentialId || null, credentialId: credentialId || null,
overrideCredentialUsername: overrideCredentialUsername ? 1 : 0,
pin: pin ? 1 : 0, pin: pin ? 1 : 0,
enableTerminal: enableTerminal ? 1 : 0, enableTerminal: enableTerminal ? 1 : 0,
enableTunnel: enableTunnel ? 1 : 0, enableTunnel: enableTunnel ? 1 : 0,
@@ -310,7 +322,9 @@ router.post(
socks5Port: socks5Port || null, socks5Port: socks5Port || null,
socks5Username: socks5Username || null, socks5Username: socks5Username || null,
socks5Password: socks5Password || null, socks5Password: socks5Password || null,
socks5ProxyChain: socks5ProxyChain ? JSON.stringify(socks5ProxyChain) : null, socks5ProxyChain: socks5ProxyChain
? JSON.stringify(socks5ProxyChain)
: null,
}; };
if (effectiveAuthType === "password") { if (effectiveAuthType === "password") {
@@ -501,6 +515,7 @@ router.put(
socks5Username, socks5Username,
socks5Password, socks5Password,
socks5ProxyChain, socks5ProxyChain,
overrideCredentialUsername,
} = hostData; } = hostData;
// Temporary logging to debug notes and expirationDate // Temporary logging to debug notes and expirationDate
@@ -533,6 +548,7 @@ router.put(
username, username,
authType: effectiveAuthType, authType: effectiveAuthType,
credentialId: credentialId || null, credentialId: credentialId || null,
overrideCredentialUsername: overrideCredentialUsername ? 1 : 0,
pin: pin ? 1 : 0, pin: pin ? 1 : 0,
enableTerminal: enableTerminal ? 1 : 0, enableTerminal: enableTerminal ? 1 : 0,
enableTunnel: enableTunnel ? 1 : 0, enableTunnel: enableTunnel ? 1 : 0,
@@ -556,7 +572,9 @@ router.put(
socks5Port: socks5Port || null, socks5Port: socks5Port || null,
socks5Username: socks5Username || null, socks5Username: socks5Username || null,
socks5Password: socks5Password || null, socks5Password: socks5Password || null,
socks5ProxyChain: socks5ProxyChain ? JSON.stringify(socks5ProxyChain) : null, socks5ProxyChain: socks5ProxyChain
? JSON.stringify(socks5ProxyChain)
: null,
}; };
if (effectiveAuthType === "password") { if (effectiveAuthType === "password") {
@@ -754,6 +772,8 @@ router.get(
credentialId: sshData.credentialId, credentialId: sshData.credentialId,
overrideCredentialUsername: sshData.overrideCredentialUsername, overrideCredentialUsername: sshData.overrideCredentialUsername,
quickActions: sshData.quickActions, quickActions: sshData.quickActions,
notes: sshData.notes,
expirationDate: sshData.expirationDate,
// Shared access info // Shared access info
isShared: sql<boolean>`${hostAccess.id} IS NOT NULL`, isShared: sql<boolean>`${hostAccess.id} IS NOT NULL`,
@@ -767,12 +787,11 @@ router.get(
eq(hostAccess.hostId, sshData.id), eq(hostAccess.hostId, sshData.id),
or( or(
eq(hostAccess.userId, userId), eq(hostAccess.userId, userId),
roleIds.length > 0 ? inArray(hostAccess.roleId, roleIds) : sql`false`, roleIds.length > 0
), ? inArray(hostAccess.roleId, roleIds)
or( : sql`false`,
isNull(hostAccess.expiresAt),
gte(hostAccess.expiresAt, now),
), ),
or(isNull(hostAccess.expiresAt), gte(hostAccess.expiresAt, now)),
), ),
) )
.where( .where(
@@ -781,10 +800,7 @@ router.get(
and( and(
// Shared to user directly (not expired) // Shared to user directly (not expired)
eq(hostAccess.userId, userId), eq(hostAccess.userId, userId),
or( or(isNull(hostAccess.expiresAt), gte(hostAccess.expiresAt, now)),
isNull(hostAccess.expiresAt),
gte(hostAccess.expiresAt, now),
),
), ),
roleIds.length > 0 roleIds.length > 0
? and( ? and(
+1 -1
View File
@@ -917,7 +917,7 @@
"noProxyNodes": "Узлы прокси не настроены. Нажмите 'Добавить узел прокси' чтобы добавить.", "noProxyNodes": "Узлы прокси не настроены. Нажмите 'Добавить узел прокси' чтобы добавить.",
"proxyNode": "Узел прокси", "proxyNode": "Узел прокси",
"proxyType": "Тип прокси", "proxyType": "Тип прокси",
"advancedAuthSettings": "Расширенные настройки аутентификации" "advancedAuthSettings": "Расширенные настройки аутентификации",
"advancedAuthSettings": "Расширенные настройки аутентификации", "advancedAuthSettings": "Расширенные настройки аутентификации",
"addQuickAction": "Добавить Quick Action", "addQuickAction": "Добавить Quick Action",
"allHostsInFolderDeleted": "{{count}} хостов успешно удалены из папки \"{{folder}}\"", "allHostsInFolderDeleted": "{{count}} хостов успешно удалены из папки \"{{folder}}\"",
@@ -870,15 +870,6 @@ export function HostManagerEditor({
...data, ...data,
}; };
if (proxyMode === "single") {
submitData.socks5ProxyChain = [];
} else if (proxyMode === "chain") {
submitData.socks5Host = "";
submitData.socks5Port = 1080;
submitData.socks5Username = "";
submitData.socks5Password = "";
}
if (data.authType !== "credential") { if (data.authType !== "credential") {
submitData.credentialId = undefined; submitData.credentialId = undefined;
} }
+24 -7
View File
@@ -3244,7 +3244,9 @@ export async function updateRole(
} }
} }
export async function deleteRole(roleId: number): Promise<{ success: boolean }> { export async function deleteRole(
roleId: number,
): Promise<{ success: boolean }> {
try { try {
const response = await rbacApi.delete(`/rbac/roles/${roleId}`); const response = await rbacApi.delete(`/rbac/roles/${roleId}`);
return response.data; return response.data;
@@ -3254,7 +3256,9 @@ export async function deleteRole(roleId: number): Promise<{ success: boolean }>
} }
// User-Role Management // User-Role Management
export async function getUserRoles(userId: string): Promise<{ roles: UserRole[] }> { export async function getUserRoles(
userId: string,
): Promise<{ roles: UserRole[] }> {
try { try {
const response = await rbacApi.get(`/rbac/users/${userId}/roles`); const response = await rbacApi.get(`/rbac/users/${userId}/roles`);
return response.data; return response.data;
@@ -3268,7 +3272,9 @@ export async function assignRoleToUser(
roleId: number, roleId: number,
): Promise<{ success: boolean }> { ): Promise<{ success: boolean }> {
try { try {
const response = await rbacApi.post(`/rbac/users/${userId}/roles`, { roleId }); const response = await rbacApi.post(`/rbac/users/${userId}/roles`, {
roleId,
});
return response.data; return response.data;
} catch (error) { } catch (error) {
throw handleApiError(error, "assign role to user"); throw handleApiError(error, "assign role to user");
@@ -3280,7 +3286,9 @@ export async function removeRoleFromUser(
roleId: number, roleId: number,
): Promise<{ success: boolean }> { ): Promise<{ success: boolean }> {
try { try {
const response = await rbacApi.delete(`/rbac/users/${userId}/roles/${roleId}`); const response = await rbacApi.delete(
`/rbac/users/${userId}/roles/${roleId}`,
);
return response.data; return response.data;
} catch (error) { } catch (error) {
throw handleApiError(error, "remove role from user"); throw handleApiError(error, "remove role from user");
@@ -3299,14 +3307,19 @@ export async function shareHost(
}, },
): Promise<{ success: boolean }> { ): Promise<{ success: boolean }> {
try { try {
const response = await rbacApi.post(`/rbac/host/${hostId}/share`, shareData); const response = await rbacApi.post(
`/rbac/host/${hostId}/share`,
shareData,
);
return response.data; return response.data;
} catch (error) { } catch (error) {
throw handleApiError(error, "share host"); throw handleApiError(error, "share host");
} }
} }
export async function getHostAccess(hostId: number): Promise<{ accessList: AccessRecord[] }> { export async function getHostAccess(
hostId: number,
): Promise<{ accessList: AccessRecord[] }> {
try { try {
const response = await rbacApi.get(`/rbac/host/${hostId}/access`); const response = await rbacApi.get(`/rbac/host/${hostId}/access`);
return response.data; return response.data;
@@ -3320,10 +3333,14 @@ export async function revokeHostAccess(
accessId: number, accessId: number,
): Promise<{ success: boolean }> { ): Promise<{ success: boolean }> {
try { try {
const response = await rbacApi.delete(`/rbac/host/${hostId}/access/${accessId}`); const response = await rbacApi.delete(
`/rbac/host/${hostId}/access/${accessId}`,
);
return response.data; return response.data;
} catch (error) { } catch (error) {
throw handleApiError(error, "revoke host access"); throw handleApiError(error, "revoke host access");
}
}
// ============================================================================ // ============================================================================
// DOCKER MANAGEMENT API // DOCKER MANAGEMENT API