fix: session F5, terminal module core, logs proxmox

- 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 <noreply@anthropic.com>
This commit is contained in:
enzo 2026-03-21 00:07:02 +01:00
parent 88831e3967
commit 1886071922
3 changed files with 11 additions and 1 deletions

View file

@ -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
}

View file

@ -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';

View file

@ -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é