From 1886071922391331b1026b3882fe8a50ee2bf7bf Mon Sep 17 00:00:00 2001 From: enzo Date: Sat, 21 Mar 2026 00:07:02 +0100 Subject: [PATCH] fix: session F5, terminal module core, logs proxmox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - router: tryRefresh() au premier chargement → plus besoin de se reconnecter après F5 (user restauré depuis le cookie refresh) - migration 003: terminal marqué is_core=1 + is_enabled=1 - proxmox.go: logs pour diagnostiquer l'erreur 502 (visible dans Paramètres → Logs) Co-Authored-By: Claude Sonnet 4.6 --- backend/internal/api/proxmox.go | 5 +++++ backend/internal/db/migrations/003_terminal_core.sql | 3 +++ frontend/src/router/index.ts | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 backend/internal/db/migrations/003_terminal_core.sql diff --git a/backend/internal/api/proxmox.go b/backend/internal/api/proxmox.go index 086aa75..c199e06 100644 --- a/backend/internal/api/proxmox.go +++ b/backend/internal/api/proxmox.go @@ -2,6 +2,7 @@ package api import ( + "log" "net/http" "strconv" "time" @@ -49,12 +50,15 @@ func (h *ProxmoxHandler) initClient() { url, _, _ := h.db.GetSetting("proxmox_url") encryptedToken, _, _ := h.db.GetSetting("proxmox_token") if url == "" || encryptedToken == "" { + log.Printf("[proxmox/init] Client non initialisé — proxmox_url=%q token_empty=%v", url, encryptedToken == "") return } token, err := h.encryptor.Decrypt(encryptedToken) if err != nil { + log.Printf("[proxmox/init] Impossible de déchiffrer le token : %v", err) return } + log.Printf("[proxmox/init] Client initialisé — url=%s", url) h.client = proxmox.NewClient(url, token) } @@ -71,6 +75,7 @@ func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) { resources, err := h.client.GetResources("") if err != nil { + log.Printf("[proxmox/resources] Erreur API : %v", err) JSONError(w, "Erreur API Proxmox : "+err.Error(), http.StatusBadGateway) return } diff --git a/backend/internal/db/migrations/003_terminal_core.sql b/backend/internal/db/migrations/003_terminal_core.sql new file mode 100644 index 0000000..aeaa7c8 --- /dev/null +++ b/backend/internal/db/migrations/003_terminal_core.sql @@ -0,0 +1,3 @@ +-- Migration 003 : Terminal marqué comme module CORE actif +-- Le terminal SSH est implémenté (api/terminal.go), il doit être core+enabled. +UPDATE modules SET is_core = 1, is_enabled = 1 WHERE id = 'terminal'; diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index bbb7e17..e1952ec 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -92,9 +92,11 @@ const router = createRouter({ router.beforeEach(async (to) => { const authStore = useAuthStore() - // Vérifier si l'application est installée (appel API au premier chargement) + // Au premier chargement : vérifier l'installation ET restaurer la session if (!authStore.installChecked) { await authStore.checkInstallation() + // Restaurer la session depuis le cookie refresh si un token est en localStorage + await authStore.tryRefresh() } // Rediriger vers l'installation si pas encore configuré