fix(backend): keep mdmId when device exists but is disenrolled; add exists flag
This commit is contained in:
parent
bb8e0d3f62
commit
e14a36f95a
@ -58,8 +58,8 @@ export default defineEventHandler(async (event) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// UDID stored but no longer present in NanoMDM → clear stale link.
|
// UDID stored but the device is completely gone from NanoMDM → clear stale link.
|
||||||
if (!status.enrolled) {
|
if (!status.exists) {
|
||||||
await clearUserDeviceMdmId(user.id, deviceId);
|
await clearUserDeviceMdmId(user.id, deviceId);
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
|
|||||||
@ -116,6 +116,7 @@ export async function getLinkedUserDevices(): Promise<
|
|||||||
|
|
||||||
export interface MdmDeviceStatus {
|
export interface MdmDeviceStatus {
|
||||||
enrolled: boolean;
|
enrolled: boolean;
|
||||||
|
exists: boolean;
|
||||||
company: string | null;
|
company: string | null;
|
||||||
supervised: boolean;
|
supervised: boolean;
|
||||||
tokenUpdateAt: Date | null;
|
tokenUpdateAt: Date | null;
|
||||||
@ -177,12 +178,14 @@ export async function getMdmStatusByUdid(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const row = result.rows[0];
|
const row = result.rows[0];
|
||||||
|
const exists = row !== undefined;
|
||||||
const enrolled = row?.enrolled ?? false;
|
const enrolled = row?.enrolled ?? false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
enrolled,
|
enrolled,
|
||||||
|
exists,
|
||||||
company: enrolled ? "ReBreak" : null,
|
company: enrolled ? "ReBreak" : null,
|
||||||
supervised: enrolled && row?.unlock_token != null,
|
supervised: exists && row?.unlock_token != null,
|
||||||
tokenUpdateAt: row?.token_update_at ?? null,
|
tokenUpdateAt: row?.token_update_at ?? null,
|
||||||
lastAckAt: row?.last_ack ?? null,
|
lastAckAt: row?.last_ack ?? null,
|
||||||
lastAppPushAt: row?.last_app_push_at ?? null,
|
lastAppPushAt: row?.last_app_push_at ?? null,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user