mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 19:46:18 +00:00
Update proxmox-dashboard.tsx
This commit is contained in:
@@ -294,39 +294,45 @@ export function ProxmoxDashboard() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const checkAuth = async () => {
|
const checkAuth = async () => {
|
||||||
console.log("[v0] Checking authentication status...")
|
console.log("[v0] ===== AUTH CHECK START =====")
|
||||||
|
console.log("[v0] Current URL:", window.location.href)
|
||||||
|
console.log("[v0] Window origin:", window.location.origin)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const token = localStorage.getItem("proxmenux-auth-token")
|
const token = localStorage.getItem("proxmenux-auth-token")
|
||||||
const hasDeclined = localStorage.getItem("proxmenux-auth-declined") === "true"
|
const hasDeclined = localStorage.getItem("proxmenux-auth-declined") === "true"
|
||||||
|
|
||||||
|
console.log("[v0] Token in localStorage:", token ? "EXISTS" : "NOT FOUND")
|
||||||
|
console.log("[v0] Has declined flag:", hasDeclined)
|
||||||
|
|
||||||
const headers: HeadersInit = { "Content-Type": "application/json" }
|
const headers: HeadersInit = { "Content-Type": "application/json" }
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
headers["Authorization"] = `Bearer ${token}`
|
headers["Authorization"] = `Bearer ${token}`
|
||||||
console.log("[v0] Found token in localStorage")
|
|
||||||
} else {
|
|
||||||
console.log("[v0] No token found in localStorage")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiUrl = getApiUrl("/api/auth/status")
|
const apiUrl = getApiUrl("/api/auth/status")
|
||||||
console.log("[v0] Calling auth status API:", apiUrl)
|
console.log("[v0] Auth status API URL:", apiUrl)
|
||||||
|
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl, {
|
||||||
headers,
|
headers,
|
||||||
})
|
})
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
console.log("[v0] Auth status response:", data)
|
console.log("[v0] Auth status response data:", JSON.stringify(data, null, 2))
|
||||||
|
|
||||||
setAuthRequired(data.auth_enabled)
|
setAuthRequired(data.auth_enabled)
|
||||||
setIsAuthenticated(data.authenticated)
|
setIsAuthenticated(data.authenticated)
|
||||||
|
|
||||||
// If auth is not configured and user hasn't declined, show the modal
|
// If auth is not configured and user hasn't declined, show the modal
|
||||||
const shouldShowModal = !data.auth_configured && !hasDeclined
|
const shouldShowModal = !data.auth_configured && !hasDeclined
|
||||||
|
console.log("[v0] Auth configured:", data.auth_configured)
|
||||||
|
console.log("[v0] Should show modal:", shouldShowModal)
|
||||||
|
|
||||||
setAuthDeclined(!shouldShowModal)
|
setAuthDeclined(!shouldShowModal)
|
||||||
setAuthChecked(true)
|
setAuthChecked(true)
|
||||||
|
|
||||||
console.log("[v0] Auth state:", {
|
console.log("[v0] Final auth state:", {
|
||||||
authRequired: data.auth_enabled,
|
authRequired: data.auth_enabled,
|
||||||
isAuthenticated: data.authenticated,
|
isAuthenticated: data.authenticated,
|
||||||
authConfigured: data.auth_configured,
|
authConfigured: data.auth_configured,
|
||||||
@@ -334,12 +340,14 @@ export function ProxmoxDashboard() {
|
|||||||
shouldShowModal: shouldShowModal,
|
shouldShowModal: shouldShowModal,
|
||||||
authDeclined: !shouldShowModal,
|
authDeclined: !shouldShowModal,
|
||||||
})
|
})
|
||||||
|
console.log("[v0] ===== AUTH CHECK END =====")
|
||||||
|
|
||||||
if (data.authenticated && token) {
|
if (data.authenticated && token) {
|
||||||
setupTokenRefresh()
|
setupTokenRefresh()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[v0] Failed to check auth status:", error)
|
console.error("[v0] Failed to check auth status:", error)
|
||||||
|
console.log("[v0] ===== AUTH CHECK FAILED =====")
|
||||||
setAuthDeclined(false)
|
setAuthDeclined(false)
|
||||||
setAuthChecked(true)
|
setAuthChecked(true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user