Initial commit — Stupid Simple Network Inventory
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>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user