|
|
@ -627,7 +627,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if err := db.UpdateTrainerIds(trainerId, secretId, uuid); err != nil {
|
|
|
|
if err = db.UpdateTrainerIds(trainerId, secretId, uuid); err != nil {
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
httpError(w, r, err, http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -646,24 +646,23 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type SessionVerifyResponse struct {
|
|
|
|
type SystemVerifyResponse struct {
|
|
|
|
Valid bool `json:"valid"`
|
|
|
|
Valid bool `json:"valid"`
|
|
|
|
SessionData *defs.SessionSaveData `json:"sessionData"`
|
|
|
|
SystemData *defs.SystemSaveData `json:"systemData"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type SessionVerifyRequest struct {
|
|
|
|
type SystemVerifyRequest struct {
|
|
|
|
ClientSessionId string `json:"clientSessionId"`
|
|
|
|
ClientSessionId string `json:"clientSessionId"`
|
|
|
|
Slot int `json:"slot"`
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func handleSessionVerify(w http.ResponseWriter, r *http.Request) {
|
|
|
|
func handleSystemVerify(w http.ResponseWriter, r *http.Request) {
|
|
|
|
uuid, err := uuidFromRequest(r)
|
|
|
|
uuid, err := uuidFromRequest(r)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, err, http.StatusBadRequest)
|
|
|
|
httpError(w, r, err, http.StatusBadRequest)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var input SessionVerifyRequest
|
|
|
|
var input SystemVerifyRequest
|
|
|
|
err = json.NewDecoder(r.Body).Decode(&input)
|
|
|
|
err = json.NewDecoder(r.Body).Decode(&input)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest)
|
|
|
|
httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest)
|
|
|
@ -677,7 +676,7 @@ func handleSessionVerify(w http.ResponseWriter, r *http.Request) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response := SessionVerifyResponse{
|
|
|
|
response := SystemVerifyResponse{
|
|
|
|
Valid: active,
|
|
|
|
Valid: active,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -689,14 +688,14 @@ func handleSessionVerify(w http.ResponseWriter, r *http.Request) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var storedSaveData defs.SessionSaveData
|
|
|
|
var storedSaveData defs.SystemSaveData
|
|
|
|
storedSaveData, err = db.ReadSessionSaveData(uuid, input.Slot)
|
|
|
|
storedSaveData, err = db.ReadSystemSaveData(uuid)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
httpError(w, r, fmt.Errorf("failed to read session save data: %s", err), http.StatusInternalServerError)
|
|
|
|
httpError(w, r, fmt.Errorf("failed to read session save data: %s", err), http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.SessionData = &storedSaveData
|
|
|
|
response.SystemData = &storedSaveData
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
jsonResponse(w, r, response)
|
|
|
|
jsonResponse(w, r, response)
|
|
|
@ -733,6 +732,7 @@ func handleGetSystemData(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO apply vouchers
|
|
|
|
|
|
|
|
|
|
|
|
jsonResponse(w, r, save)
|
|
|
|
jsonResponse(w, r, save)
|
|
|
|
}
|
|
|
|
}
|
|
|
|