mirror of
https://github.com/freedbygrace/ActiveDirectoryManager.git
synced 2026-07-26 11:59:14 +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
|
||||
const {
|
||||
data: connections,
|
||||
data: connections = [],
|
||||
isLoading: connectionsLoading
|
||||
} = useQuery({
|
||||
} = useQuery<LdapConnection[]>({
|
||||
queryKey: ["/api/ldap-connections"],
|
||||
enabled: !!user
|
||||
});
|
||||
|
||||
// Query to get LDAP filters for the selected connection
|
||||
const {
|
||||
data: filters,
|
||||
data: filters = [],
|
||||
isLoading: filtersLoading
|
||||
} = useQuery({
|
||||
} = useQuery<LdapFilter[]>({
|
||||
queryKey: ["/api/connections", selectedConnectionId, "ldap-filters"],
|
||||
enabled: !!selectedConnectionId,
|
||||
});
|
||||
|
||||
// Query to get LDAP filter revisions
|
||||
const {
|
||||
data: revisions,
|
||||
data: revisions = [],
|
||||
isLoading: revisionsLoading,
|
||||
refetch: refetchRevisions
|
||||
} = useQuery({
|
||||
} = useQuery<LdapFilterRevision[]>({
|
||||
queryKey: ["/api/ldap-filters", selectedFilter?.id, "revisions"],
|
||||
enabled: !!selectedFilter?.id && showRevisionsDialog,
|
||||
});
|
||||
|
||||
+8
-8
@@ -590,12 +590,12 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
// Apply where conditions if any
|
||||
if (whereClause) {
|
||||
baseQuery = baseQuery.where(whereClause);
|
||||
baseQuery = baseQuery.where(whereClause as any);
|
||||
}
|
||||
|
||||
// Apply ordering if any
|
||||
if (orderClauses.length > 0) {
|
||||
baseQuery = baseQuery.orderBy(...orderClauses);
|
||||
if (orderClauses && orderClauses.length > 0) {
|
||||
baseQuery = baseQuery.orderBy(...(orderClauses as any[]));
|
||||
}
|
||||
|
||||
// Apply pagination if specified
|
||||
@@ -611,7 +611,7 @@ export class DatabaseStorage implements IStorage {
|
||||
const users = await baseQuery;
|
||||
|
||||
// Handle field selection if specified
|
||||
if (selectedFields.length > 0) {
|
||||
if (selectedFields && selectedFields.length > 0) {
|
||||
const result = users.map(user => {
|
||||
const filtered: Partial<AdUser> = { id: user.id };
|
||||
selectedFields.forEach(field => {
|
||||
@@ -679,12 +679,12 @@ export class DatabaseStorage implements IStorage {
|
||||
|
||||
// Apply where conditions if any
|
||||
if (whereClause) {
|
||||
baseQuery = baseQuery.where(whereClause);
|
||||
baseQuery = baseQuery.where(whereClause as any);
|
||||
}
|
||||
|
||||
// Apply ordering if any
|
||||
if (orderClauses.length > 0) {
|
||||
baseQuery = baseQuery.orderBy(...orderClauses);
|
||||
if (orderClauses && orderClauses.length > 0) {
|
||||
baseQuery = baseQuery.orderBy(...(orderClauses as any[]));
|
||||
}
|
||||
|
||||
// Apply pagination if specified
|
||||
@@ -700,7 +700,7 @@ export class DatabaseStorage implements IStorage {
|
||||
const groups = await baseQuery;
|
||||
|
||||
// Handle field selection if specified
|
||||
if (selectedFields.length > 0) {
|
||||
if (selectedFields && selectedFields.length > 0) {
|
||||
const result = groups.map(group => {
|
||||
const filtered: Partial<AdGroup> = { id: group.id };
|
||||
selectedFields.forEach(field => {
|
||||
|
||||
Reference in New Issue
Block a user