[Beta][Bug] Preventing Run History encryption (#3933)

* Blah

* Thought about it more

* Removed excess comment

* Purposely tested everything by manually setting bypassLogin to false

---------

Co-authored-by: frutescens <info@laptop>
This commit is contained in:
Mumble 2024-08-30 23:12:47 -07:00 committed by GitHub
parent ce0ba3fbf9
commit f8e119f37e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -464,7 +464,7 @@ export class GameData {
const lsItemKey = `runHistoryData_${loggedInUser?.username}`; const lsItemKey = `runHistoryData_${loggedInUser?.username}`;
const lsItem = localStorage.getItem(lsItemKey); const lsItem = localStorage.getItem(lsItemKey);
if (!lsItem) { if (!lsItem) {
localStorage.setItem(lsItemKey, encrypt("", true)); localStorage.setItem(lsItemKey, "");
} }
this.trainerId = systemData.trainerId; this.trainerId = systemData.trainerId;
@ -594,7 +594,7 @@ export class GameData {
if (lsItem) { if (lsItem) {
const cachedResponse = lsItem; const cachedResponse = lsItem;
if (cachedResponse) { if (cachedResponse) {
const runHistory = JSON.parse(decrypt(cachedResponse, true)); const runHistory = JSON.parse(decrypt(cachedResponse, bypassLogin));
return runHistory; return runHistory;
} }
return {}; return {};
@ -616,7 +616,7 @@ export class GameData {
if (lsItem) { if (lsItem) {
const cachedResponse = lsItem; const cachedResponse = lsItem;
if (cachedResponse) { if (cachedResponse) {
const runHistory : RunHistoryData = JSON.parse(decrypt(cachedResponse, true)); const runHistory : RunHistoryData = JSON.parse(decrypt(cachedResponse, bypassLogin));
return runHistory; return runHistory;
} }
return {}; return {};
@ -652,7 +652,7 @@ export class GameData {
isVictory: isVictory, isVictory: isVictory,
isFavorite: false, isFavorite: false,
}; };
localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, encrypt(JSON.stringify(runHistoryData), true)); localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, encrypt(JSON.stringify(runHistoryData), bypassLogin));
/** /**
* Networking Code DO NOT DELETE * Networking Code DO NOT DELETE
* *
@ -1368,8 +1368,7 @@ export class GameData {
} else { } else {
const data = localStorage.getItem(dataKey); const data = localStorage.getItem(dataKey);
if (data) { if (data) {
handleData(decrypt(data, (dataType !== GameDataType.RUN_HISTORY) ? bypassLogin : true)); handleData(decrypt(data, bypassLogin));
// This conditional is necessary because at the moment, run history is stored locally only so it has to be decoded from Base64 as if it was local
} }
resolve(!!data); resolve(!!data);
} }
@ -1418,9 +1417,6 @@ export class GameData {
const entryKeys = Object.keys(data[key]); const entryKeys = Object.keys(data[key]);
valid = ["isFavorite", "isVictory", "entry"].every(v => entryKeys.includes(v)) && entryKeys.length === 3; valid = ["isFavorite", "isVictory", "entry"].every(v => entryKeys.includes(v)) && entryKeys.length === 3;
}); });
if (valid) {
localStorage.setItem(`runHistoryData_${loggedInUser?.username}`, dataStr);
}
break; break;
case GameDataType.SETTINGS: case GameDataType.SETTINGS:
case GameDataType.TUTORIALS: case GameDataType.TUTORIALS: