88cf6458d0
Application web d'inventaire réseau manuel avec FastAPI, Vue 3 et Docker. Inclut l'authentification JWT, la découverte ICMP, et la topologie en cards CSS. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
import { ref, computed } from 'vue'
|
|
|
|
const _token = ref(localStorage.getItem('auth_token') || null)
|
|
const _username = ref(localStorage.getItem('auth_username') || null)
|
|
const _mustChange = ref(localStorage.getItem('auth_mustchange') === 'true')
|
|
|
|
export const isAuthenticated = computed(() => !!_token.value)
|
|
export const currentUsername = computed(() => _username.value)
|
|
export const mustChangePassword = computed(() => _mustChange.value)
|
|
|
|
export function setAuth(token, username, mustChange = false) {
|
|
_token.value = token
|
|
_username.value = username
|
|
_mustChange.value = mustChange
|
|
localStorage.setItem('auth_token', token)
|
|
localStorage.setItem('auth_username', username)
|
|
localStorage.setItem('auth_mustchange', String(mustChange))
|
|
}
|
|
|
|
export function clearAuth() {
|
|
_token.value = null
|
|
_username.value = null
|
|
_mustChange.value = false
|
|
localStorage.removeItem('auth_token')
|
|
localStorage.removeItem('auth_username')
|
|
localStorage.removeItem('auth_mustchange')
|
|
}
|
|
|
|
export function getToken() {
|
|
return _token.value
|
|
}
|