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) {
}) })
} }
} }
const verifyAuth = () => {
export const updateSystemList = () => { pb.collection('users')
pb.collection<SystemRecord>('systems') .authRefresh()
.getFullList({ sort: '+name' }) .catch(() => {
.then((records) => { pb.authStore.clear()
$systems.set(records)
}) })
} }
export const updateSystemList = async () => {
try {
const records = await pb.collection<SystemRecord>('systems').getFullList({ sort: '+name' })
$systems.set(records)
} catch (e) {
verifyAuth()
}
}
export const updateAlerts = () => { export const updateAlerts = () => {
pb.collection('alerts') pb.collection('alerts')
.getFullList<AlertRecord>({ fields: 'id,name,system' }) .getFullList<AlertRecord>({ fields: 'id,name,system' })