Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions apps/app/src/app/(app)/[orgId]/people/devices/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ export const getEmployeeDevicesFromDB: () => Promise<DeviceWithChecks[]> = async
}

const devices = await db.device.findMany({
where: { organizationId },
where: {
organizationId,
// Exclude devices for users whose User.role is platform admin (not org Member.role).
NOT: {
member: {
user: {
role: 'admin',
},
},
},
},
include: {
member: {
include: {
Expand Down Expand Up @@ -65,7 +75,7 @@ export const getEmployeeDevicesFromDB: () => Promise<DeviceWithChecks[]> = async

/**
* Fetches Fleet (legacy) devices for the current organization.
* Returns Host[] exactly as main branch — untouched Fleet logic.
* Excludes members whose User.role is platform admin (same as getEmployeeDevicesFromDB).
*/
export const getFleetHosts: () => Promise<Host[] | null> = async () => {
const session = await auth.api.getSession({
Expand All @@ -80,11 +90,16 @@ export const getFleetHosts: () => Promise<Host[] | null> = async () => {
return null;
}

// Find all members belonging to the organization.
// Members with Fleet labels (exclude platform admins — same filter as device-agent path).
const employees = await db.member.findMany({
where: {
organizationId,
deactivated: false,
NOT: {
user: {
role: 'admin',
},
},
},
include: {
user: true,
Expand Down
Loading