mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-07-11 19:02:17 +02:00
Compare commits
No commits in common. "509ca8df1275f786e69b1107e41c1d43cd5c875f" and "a063b1740c452755e7df5a3b5a688b921df06443" have entirely different histories.
509ca8df12
...
a063b1740c
@ -297,19 +297,19 @@ func clearSessionData(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if storedTrainerId > 0 || storedSecretId > 0 {
|
||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = db.UpdateTrainerIds(trainerId, secretId, uuid)
|
||||
if err != nil {
|
||||
httpError(w, r, fmt.Errorf("unable to update trainer ID: %s", err), http.StatusInternalServerError)
|
||||
httpError(w, r, fmt.Errorf("unable to update traienr ID: %s", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if !active {
|
||||
save = savedata.ClearResponse{Error: "session out of date: not active"}
|
||||
save = savedata.ClearResponse{Error: "session out of date"}
|
||||
}
|
||||
|
||||
var seed string
|
||||
@ -362,7 +362,7 @@ func deleteSystemSave(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if !active {
|
||||
httpError(w, r, fmt.Errorf("session out of date: not active"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ func deleteSystemSave(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if storedTrainerId > 0 || storedSecretId > 0 {
|
||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -485,7 +485,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// TODO: make this not suck
|
||||
if !active && r.URL.Path != "/savedata/clear" {
|
||||
httpError(w, r, fmt.Errorf("session out of date: not active"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@ -518,7 +518,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if storedTrainerId > 0 || storedSecretId > 0 {
|
||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -543,7 +543,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) {
|
||||
case "/savedata/clear":
|
||||
if !active {
|
||||
// TODO: make this not suck
|
||||
save = savedata.ClearResponse{Error: "session out of date: not active"}
|
||||
save = savedata.ClearResponse{Error: "session out of date"}
|
||||
break
|
||||
}
|
||||
|
||||
@ -603,7 +603,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if !active {
|
||||
httpError(w, r, fmt.Errorf("session out of date: not active"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@ -618,7 +618,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if storedTrainerId > 0 || storedSecretId > 0 {
|
||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -47,11 +47,6 @@ func Update(uuid []byte, slot int, save any) error {
|
||||
return fmt.Errorf("failed to update account stats: %s", err)
|
||||
}
|
||||
|
||||
err = db.DeleteClaimedAccountCompensations(uuid)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete claimed compensations: %s", err)
|
||||
}
|
||||
|
||||
return db.StoreSystemSaveData(uuid, save)
|
||||
|
||||
case defs.SessionSaveData: // Session
|
||||
|
@ -215,16 +215,19 @@ func IsActiveSession(uuid []byte, clientSessionId string) (bool, error) {
|
||||
err := handle.QueryRow("SELECT clientSessionId FROM activeClientSessions WHERE uuid = ?", uuid).Scan(&storedId)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
err = UpdateActiveSession(uuid, clientSessionId)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
if storedId == "" {
|
||||
err = UpdateActiveSession(uuid, clientSessionId)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return storedId == "" || storedId == clientSessionId, nil
|
||||
return storedId == clientSessionId, nil
|
||||
}
|
||||
|
||||
func UpdateActiveSession(uuid []byte, clientSessionId string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user