mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-07-11 02:42:20 +02:00
Compare commits
4 Commits
a063b1740c
...
509ca8df12
Author | SHA1 | Date | |
---|---|---|---|
|
509ca8df12 | ||
|
f31f130c14 | ||
|
c17c583321 | ||
|
76e7ba02ad |
@ -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"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = db.UpdateTrainerIds(trainerId, secretId, uuid)
|
||||
if err != nil {
|
||||
httpError(w, r, fmt.Errorf("unable to update traienr ID: %s", err), http.StatusInternalServerError)
|
||||
httpError(w, r, fmt.Errorf("unable to update trainer ID: %s", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if !active {
|
||||
save = savedata.ClearResponse{Error: "session out of date"}
|
||||
save = savedata.ClearResponse{Error: "session out of date: not active"}
|
||||
}
|
||||
|
||||
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"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date: not active"), 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"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), 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"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date: not active"), 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"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), 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"}
|
||||
save = savedata.ClearResponse{Error: "session out of date: not active"}
|
||||
break
|
||||
}
|
||||
|
||||
@ -603,7 +603,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if !active {
|
||||
httpError(w, r, fmt.Errorf("session out of date"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date: not active"), 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"), http.StatusBadRequest)
|
||||
httpError(w, r, fmt.Errorf("session out of date: stored trainer or secret ID does not match"), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
@ -47,6 +47,11 @@ 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,19 +215,16 @@ 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) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
if storedId == "" {
|
||||
err = UpdateActiveSession(uuid, clientSessionId)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
|
||||
return storedId == clientSessionId, nil
|
||||
return storedId == "" || storedId == clientSessionId, nil
|
||||
}
|
||||
|
||||
func UpdateActiveSession(uuid []byte, clientSessionId string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user