verify auth if error fetching systems

This commit is contained in:
Henry Dollman
2024-07-22 11:05:14 -04:00
parent 8f4659b356
commit b1d994a0ff

View File

@@ -26,15 +26,23 @@ export async function copyToClipboard(content: string) {
})
}
}
export const updateSystemList = () => {
pb.collection<SystemRecord>('systems')
.getFullList({ sort: '+name' })
.then((records) => {
$systems.set(records)
const verifyAuth = () => {
pb.collection('users')
.authRefresh()
.catch(() => {
pb.authStore.clear()
})
}
export const updateSystemList = async () => {
try {
const records = await pb.collection<SystemRecord>('systems').getFullList({ sort: '+name' })
$systems.set(records)
} catch (e) {
verifyAuth()
}
}
export const updateAlerts = () => {
pb.collection('alerts')
.getFullList<AlertRecord>({ fields: 'id,name,system' })