Save devices without user binding
This commit is contained in:
parent
cc411fb88e
commit
fe8a3e2217
|
@ -95,6 +95,32 @@ async function updateDB(onlineDevices) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// If is a binding problem, probably the device has an user outside of AD, so save it anyway...
|
||||||
|
if (e.code == 'P2016')
|
||||||
|
try {
|
||||||
|
await forceUserDisconnect(device.mac)
|
||||||
|
await prisma.wifiDevice.upsert({
|
||||||
|
where: { mac: device.mac },
|
||||||
|
create: {
|
||||||
|
...device,
|
||||||
|
hostname,
|
||||||
|
firstSeen: device.firstSeen || new Date(),
|
||||||
|
user: undefined
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
...device,
|
||||||
|
hostname,
|
||||||
|
user: undefined
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
logError({
|
||||||
|
tags: ['wifiDevices'],
|
||||||
|
message: `Error trying to upsert device with mac "${device.mac}". It has an user, but not in AD. And fails anyway...`,
|
||||||
|
data: { error: e, device }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else
|
||||||
logError({
|
logError({
|
||||||
tags: ['wifiDevices'],
|
tags: ['wifiDevices'],
|
||||||
message: `Error trying to upsert device with mac "${device.mac}"`,
|
message: `Error trying to upsert device with mac "${device.mac}"`,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user