mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-07-11 10:52:18 +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 storedTrainerId > 0 || storedSecretId > 0 {
|
||||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
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
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = db.UpdateTrainerIds(trainerId, secretId, uuid)
|
err = db.UpdateTrainerIds(trainerId, secretId, uuid)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !active {
|
if !active {
|
||||||
save = savedata.ClearResponse{Error: "session out of date"}
|
save = savedata.ClearResponse{Error: "session out of date: not active"}
|
||||||
}
|
}
|
||||||
|
|
||||||
var seed string
|
var seed string
|
||||||
@ -362,7 +362,7 @@ func deleteSystemSave(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !active {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ func deleteSystemSave(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if storedTrainerId > 0 || storedSecretId > 0 {
|
if storedTrainerId > 0 || storedSecretId > 0 {
|
||||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
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
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -485,7 +485,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// TODO: make this not suck
|
// TODO: make this not suck
|
||||||
if !active && r.URL.Path != "/savedata/clear" {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +518,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if storedTrainerId > 0 || storedSecretId > 0 {
|
if storedTrainerId > 0 || storedSecretId > 0 {
|
||||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
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
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -543,7 +543,7 @@ func legacyHandleSaveData(w http.ResponseWriter, r *http.Request) {
|
|||||||
case "/savedata/clear":
|
case "/savedata/clear":
|
||||||
if !active {
|
if !active {
|
||||||
// TODO: make this not suck
|
// TODO: make this not suck
|
||||||
save = savedata.ClearResponse{Error: "session out of date"}
|
save = savedata.ClearResponse{Error: "session out of date: not active"}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,7 +603,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !active {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +618,7 @@ func handleUpdateAll(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if storedTrainerId > 0 || storedSecretId > 0 {
|
if storedTrainerId > 0 || storedSecretId > 0 {
|
||||||
if trainerId != storedTrainerId || secretId != storedSecretId {
|
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
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -47,6 +47,11 @@ func Update(uuid []byte, slot int, save any) error {
|
|||||||
return fmt.Errorf("failed to update account stats: %s", err)
|
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)
|
return db.StoreSystemSaveData(uuid, save)
|
||||||
|
|
||||||
case defs.SessionSaveData: // Session
|
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)
|
err := handle.QueryRow("SELECT clientSessionId FROM activeClientSessions WHERE uuid = ?", uuid).Scan(&storedId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return false, nil
|
err = UpdateActiveSession(uuid, clientSessionId)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
if storedId == "" {
|
|
||||||
err = UpdateActiveSession(uuid, clientSessionId)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return storedId == clientSessionId, nil
|
return storedId == "" || storedId == clientSessionId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateActiveSession(uuid []byte, clientSessionId string) error {
|
func UpdateActiveSession(uuid []byte, clientSessionId string) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user