Update AppImage

This commit is contained in:
MacRimi
2025-11-04 21:59:28 +01:00
parent b850e9615a
commit 77c5ad7b09
2 changed files with 39 additions and 3 deletions

View File

@@ -22,11 +22,25 @@ export function AuthSetup({ onComplete }: AuthSetupProps) {
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
useEffect(() => { useEffect(() => {
const hasSeenOnboarding = localStorage.getItem("proxmenux-onboarding-seen") const checkOnboardingStatus = async () => {
try {
const response = await fetch(getApiUrl("/api/auth/status"))
const data = await response.json()
if (hasSeenOnboarding) { console.log("[v0] Auth status for modal check:", data)
// Show modal if auth is not configured and not declined
if (!data.auth_configured) {
setTimeout(() => setOpen(true), 500) setTimeout(() => setOpen(true), 500)
} }
} catch (error) {
console.error("[v0] Failed to check auth status:", error)
// Fail-safe: show modal if we can't check status
setTimeout(() => setOpen(true), 500)
}
}
checkOnboardingStatus()
}, []) }, [])
const handleSkipAuth = async () => { const handleSkipAuth = async () => {

View File

@@ -315,12 +315,17 @@ export function ProxmoxDashboard() {
if (token) { if (token) {
headers["Authorization"] = `Bearer ${token}` headers["Authorization"] = `Bearer ${token}`
console.log("[v0] Token found in localStorage")
} else {
console.log("[v0] No token in localStorage")
} }
const apiUrl = getApiUrl("/api/auth/status") const apiUrl = getApiUrl("/api/auth/status")
console.log("[v0] Auth status API URL:", apiUrl) console.log("[v0] Auth status API URL:", apiUrl)
const response = await fetch(apiUrl, { headers }) const response = await fetch(apiUrl, { headers })
console.log("[v0] Auth status response status:", response.status)
console.log("[v0] Auth status response ok:", response.ok)
if (!response.ok) { if (!response.ok) {
throw new Error(`Auth status check failed with status: ${response.status}`) throw new Error(`Auth status check failed with status: ${response.status}`)
@@ -329,22 +334,39 @@ export function ProxmoxDashboard() {
const data = await response.json() const data = await response.json()
console.log("[v0] Auth status response data:", JSON.stringify(data, null, 2)) console.log("[v0] Auth status response data:", JSON.stringify(data, null, 2))
console.log("[v0] Setting authRequired to:", data.auth_enabled)
console.log("[v0] Setting isAuthenticated to:", data.authenticated)
console.log("[v0] auth_configured value:", data.auth_configured)
setAuthRequired(data.auth_enabled) setAuthRequired(data.auth_enabled)
setIsAuthenticated(data.authenticated) setIsAuthenticated(data.authenticated)
// auth_configured will be true if user either set up auth OR declined it // auth_configured will be true if user either set up auth OR declined it
const shouldShowModal = !data.auth_configured const shouldShowModal = !data.auth_configured
console.log("[v0] Should show modal:", shouldShowModal)
console.log("[v0] Setting authDeclined to:", data.auth_configured)
setAuthDeclined(data.auth_configured) // If configured (either way), don't show modal setAuthDeclined(data.auth_configured) // If configured (either way), don't show modal
setAuthChecked(true) setAuthChecked(true)
if (data.authenticated && token) { if (data.authenticated && token) {
setupTokenRefresh() setupTokenRefresh()
} }
console.log("[v0] ===== AUTH CHECK SUCCESS =====")
} catch (error) { } catch (error) {
console.error("[v0] ===== AUTH CHECK FAILED =====")
console.error("[v0] Failed to check auth status:", error) console.error("[v0] Failed to check auth status:", error)
console.error("[v0] Error message:", error instanceof Error ? error.message : "Unknown error")
console.log("[v0] Setting authDeclined to false (show modal on error)")
console.log("[v0] Setting authRequired to false (don't require login on error)")
setAuthDeclined(false) // Show modal when API fails setAuthDeclined(false) // Show modal when API fails
setAuthRequired(false) // Don't require login on error setAuthRequired(false) // Don't require login on error
setAuthChecked(true) setAuthChecked(true)
console.log("[v0] ===== AUTH CHECK ERROR HANDLED =====")
} }
} }