Support legacy /savedata/system/verify

pull/42/head
Pancakes 5 months ago
parent f9cce330f6
commit 23c2458d8f
No known key found for this signature in database
GPG Key ID: 5792877BFA27DC8F

@ -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
}
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
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,10 +539,18 @@ 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{

Loading…
Cancel
Save