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.
|
||||
if (!status.enrolled) {
|
||||
// UDID stored but the device is completely gone from NanoMDM → clear stale link.
|
||||
if (!status.exists) {
|
||||
await clearUserDeviceMdmId(user.id, deviceId);
|
||||
return {
|
||||
success: true,
|
||||
|
||||
@ -116,6 +116,7 @@ export async function getLinkedUserDevices(): Promise<
|
||||
|
||||
export interface MdmDeviceStatus {
|
||||
enrolled: boolean;
|
||||
exists: boolean;
|
||||
company: string | null;
|
||||
supervised: boolean;
|
||||
tokenUpdateAt: Date | null;
|
||||
@ -177,12 +178,14 @@ export async function getMdmStatusByUdid(
|
||||
);
|
||||
|
||||
const row = result.rows[0];
|
||||
const exists = row !== undefined;
|
||||
const enrolled = row?.enrolled ?? false;
|
||||
|
||||
return {
|
||||
enrolled,
|
||||
exists,
|
||||
company: enrolled ? "ReBreak" : null,
|
||||
supervised: enrolled && row?.unlock_token != null,
|
||||
supervised: exists && row?.unlock_token != null,
|
||||
tokenUpdateAt: row?.token_update_at ?? null,
|
||||
lastAckAt: row?.last_ack ?? null,
|
||||
lastAppPushAt: row?.last_app_push_at ?? null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user