File tree Expand file tree Collapse file tree
apps/app/src/app/(app)/[orgId]/people/devices/data Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,17 @@ export const getEmployeeDevicesFromDB: () => Promise<DeviceWithChecks[]> = async
2424 }
2525
2626 const devices = await db . device . findMany ( {
27- where : { organizationId } ,
27+ where : {
28+ organizationId,
29+ // Exclude devices for users whose User.role is platform admin (not org Member.role).
30+ NOT : {
31+ member : {
32+ user : {
33+ role : 'admin' ,
34+ } ,
35+ } ,
36+ } ,
37+ } ,
2838 include : {
2939 member : {
3040 include : {
@@ -65,7 +75,7 @@ export const getEmployeeDevicesFromDB: () => Promise<DeviceWithChecks[]> = async
6575
6676/**
6777 * Fetches Fleet (legacy) devices for the current organization.
68- * Returns Host[] exactly as main branch — untouched Fleet logic .
78+ * Excludes members whose User.role is platform admin (same as getEmployeeDevicesFromDB) .
6979 */
7080export const getFleetHosts : ( ) => Promise < Host [ ] | null > = async ( ) => {
7181 const session = await auth . api . getSession ( {
@@ -80,11 +90,16 @@ export const getFleetHosts: () => Promise<Host[] | null> = async () => {
8090 return null ;
8191 }
8292
83- // Find all members belonging to the organization .
93+ // Members with Fleet labels (exclude platform admins — same filter as device-agent path) .
8494 const employees = await db . member . findMany ( {
8595 where : {
8696 organizationId,
8797 deactivated : false ,
98+ NOT : {
99+ user : {
100+ role : 'admin' ,
101+ } ,
102+ } ,
88103 } ,
89104 include : {
90105 user : true ,
You can’t perform that action at this time.
0 commit comments