Files
gohoarder/frontend/src/lib/adminKey.ts
T
lukaszraczylo 671bb0625b feat(ui): redesign the dashboard as a package checkpoint
Add overview, packages with quick view, package detail tabs, a merged security page, insights, system and restyled bypasses. Old vulnerable and blocked routes redirect to the matching security tab.
2026-11-24 01:13:09 +00:00

23 lines
687 B
TypeScript

import { computed, ref } from 'vue'
const STORAGE_KEY = 'admin_api_key'
const key = ref(typeof localStorage === 'undefined' ? '' : (localStorage.getItem(STORAGE_KEY) ?? ''))
/** The admin API key the dashboard sends with admin calls; kept in localStorage. */
export function useAdminKey() {
function load() {
key.value = localStorage.getItem(STORAGE_KEY) ?? ''
}
function save(value: string) {
key.value = value
localStorage.setItem(STORAGE_KEY, value)
}
function clear() {
key.value = ''
localStorage.removeItem(STORAGE_KEY)
}
const headers = computed(() => ({ Authorization: `Bearer ${key.value}` }))
return { key, headers, load, save, clear }
}