Maxime Duchene-Savard b57cb700ec travaux
2025-04-14 09:48:25 -04:00

25 lines
491 B
TypeScript

// Utilities
import {defineStore} from 'pinia'
export const useAppStore = defineStore('app', {
state: () => ({
user: null,
}),
actions: {
async updateUser() {
const res = await fetch('/gui/auth/me')
if (res.status === 200) {
const data = await res.json()
if (data.loggedIn) {
this.user = data.user
} else {
this.user = null
}
} else if (res.status === 401) {
this.user = null
}
}
}
})