mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-08-18 06:24:31 +00:00
Fix: Handle potential undefined values in LDAP query builder and database queries.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/e6f1810b-5d83-4907-ac49-d7d4e6aaf193.jpg
This commit is contained in:
@@ -80,28 +80,28 @@ const LdapQueryBuilderPage = () => {
|
|||||||
|
|
||||||
// Query to get LDAP connections
|
// Query to get LDAP connections
|
||||||
const {
|
const {
|
||||||
data: connections,
|
data: connections = [],
|
||||||
isLoading: connectionsLoading
|
isLoading: connectionsLoading
|
||||||
} = useQuery({
|
} = useQuery<LdapConnection[]>({
|
||||||
queryKey: ["/api/ldap-connections"],
|
queryKey: ["/api/ldap-connections"],
|
||||||
enabled: !!user
|
enabled: !!user
|
||||||
});
|
});
|
||||||
|
|
||||||
// Query to get LDAP filters for the selected connection
|
// Query to get LDAP filters for the selected connection
|
||||||
const {
|
const {
|
||||||
data: filters,
|
data: filters = [],
|
||||||
isLoading: filtersLoading
|
isLoading: filtersLoading
|
||||||
} = useQuery({
|
} = useQuery<LdapFilter[]>({
|
||||||
queryKey: ["/api/connections", selectedConnectionId, "ldap-filters"],
|
queryKey: ["/api/connections", selectedConnectionId, "ldap-filters"],
|
||||||
enabled: !!selectedConnectionId,
|
enabled: !!selectedConnectionId,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Query to get LDAP filter revisions
|
// Query to get LDAP filter revisions
|
||||||
const {
|
const {
|
||||||
data: revisions,
|
data: revisions = [],
|
||||||
isLoading: revisionsLoading,
|
isLoading: revisionsLoading,
|
||||||
refetch: refetchRevisions
|
refetch: refetchRevisions
|
||||||
} = useQuery({
|
} = useQuery<LdapFilterRevision[]>({
|
||||||
queryKey: ["/api/ldap-filters", selectedFilter?.id, "revisions"],
|
queryKey: ["/api/ldap-filters", selectedFilter?.id, "revisions"],
|
||||||
enabled: !!selectedFilter?.id && showRevisionsDialog,
|
enabled: !!selectedFilter?.id && showRevisionsDialog,
|
||||||
});
|
});
|
||||||
|
|||||||
+8
-8
@@ -590,12 +590,12 @@ export class DatabaseStorage implements IStorage {
|
|||||||
|
|
||||||
// Apply where conditions if any
|
// Apply where conditions if any
|
||||||
if (whereClause) {
|
if (whereClause) {
|
||||||
baseQuery = baseQuery.where(whereClause);
|
baseQuery = baseQuery.where(whereClause as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply ordering if any
|
// Apply ordering if any
|
||||||
if (orderClauses.length > 0) {
|
if (orderClauses && orderClauses.length > 0) {
|
||||||
baseQuery = baseQuery.orderBy(...orderClauses);
|
baseQuery = baseQuery.orderBy(...(orderClauses as any[]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply pagination if specified
|
// Apply pagination if specified
|
||||||
@@ -611,7 +611,7 @@ export class DatabaseStorage implements IStorage {
|
|||||||
const users = await baseQuery;
|
const users = await baseQuery;
|
||||||
|
|
||||||
// Handle field selection if specified
|
// Handle field selection if specified
|
||||||
if (selectedFields.length > 0) {
|
if (selectedFields && selectedFields.length > 0) {
|
||||||
const result = users.map(user => {
|
const result = users.map(user => {
|
||||||
const filtered: Partial<AdUser> = { id: user.id };
|
const filtered: Partial<AdUser> = { id: user.id };
|
||||||
selectedFields.forEach(field => {
|
selectedFields.forEach(field => {
|
||||||
@@ -679,12 +679,12 @@ export class DatabaseStorage implements IStorage {
|
|||||||
|
|
||||||
// Apply where conditions if any
|
// Apply where conditions if any
|
||||||
if (whereClause) {
|
if (whereClause) {
|
||||||
baseQuery = baseQuery.where(whereClause);
|
baseQuery = baseQuery.where(whereClause as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply ordering if any
|
// Apply ordering if any
|
||||||
if (orderClauses.length > 0) {
|
if (orderClauses && orderClauses.length > 0) {
|
||||||
baseQuery = baseQuery.orderBy(...orderClauses);
|
baseQuery = baseQuery.orderBy(...(orderClauses as any[]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply pagination if specified
|
// Apply pagination if specified
|
||||||
@@ -700,7 +700,7 @@ export class DatabaseStorage implements IStorage {
|
|||||||
const groups = await baseQuery;
|
const groups = await baseQuery;
|
||||||
|
|
||||||
// Handle field selection if specified
|
// Handle field selection if specified
|
||||||
if (selectedFields.length > 0) {
|
if (selectedFields && selectedFields.length > 0) {
|
||||||
const result = groups.map(group => {
|
const result = groups.map(group => {
|
||||||
const filtered: Partial<AdGroup> = { id: group.id };
|
const filtered: Partial<AdGroup> = { id: group.id };
|
||||||
selectedFields.forEach(field => {
|
selectedFields.forEach(field => {
|
||||||
|
|||||||
Reference in New Issue
Block a user