From 23c2458d8f4acaf75464c148c201da733235da44 Mon Sep 17 00:00:00 2001 From: Pancakes Date: Mon, 10 Jun 2024 14:56:15 -0400 Subject: [PATCH] Support legacy /savedata/system/verify --- api/endpoints.go | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/api/endpoints.go b/api/endpoints.go index 2d025ce..e71962a 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -479,15 +479,18 @@ func handleSystem(w http.ResponseWriter, r *http.Request) { return } - if !r.URL.Query().Has("clientSessionId") { - httpError(w, r, fmt.Errorf("missing clientSessionId"), http.StatusBadRequest) - return - } - - active, err := db.IsActiveSession(uuid, r.URL.Query().Get("clientSessionId")) - if err != nil { - httpError(w, r, fmt.Errorf("failed to check active session: %s", err), http.StatusBadRequest) - return + var active bool + if r.URL.Path != "/savedata/system/verify" { + if !r.URL.Query().Has("clientSessionId") { + httpError(w, r, fmt.Errorf("missing clientSessionId"), http.StatusBadRequest) + return + } + + active, err = db.IsActiveSession(uuid, r.URL.Query().Get("clientSessionId")) + if err != nil { + httpError(w, r, fmt.Errorf("failed to check active session: %s", err), http.StatusBadRequest) + return + } } switch r.PathValue("action") { @@ -536,12 +539,20 @@ func handleSystem(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) case "verify": var input SystemVerifyRequest - err = json.NewDecoder(r.Body).Decode(&input) - if err != nil { - httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest) - return + if !r.URL.Query().Has("clientSessionId") { + err = json.NewDecoder(r.Body).Decode(&input) + if err != nil { + httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest) + return + } + } else { + active, err = db.IsActiveSession(uuid, r.URL.Query().Get("clientSessionId")) + if err != nil { + httpError(w, r, fmt.Errorf("failed to check active session: %s", err), http.StatusBadRequest) + return + } } - + response := SystemVerifyResponse{ Valid: active, }