Skip to content

Commit 19a3863

Browse files
Mikkel Sørensenkirre-bylund
authored andcommitted
Fixes from turborilla
1 parent e278671 commit 19a3863

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

Runtime/Client/LootLockerServerApi.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,18 @@ IEnumerator coroutine()
131131
text = webRequest.downloadHandler.text
132132
};
133133

134-
response.errorData = LootLockerJson.DeserializeObject<LootLockerErrorData>(webRequest.downloadHandler.text);
135-
134+
try
135+
{
136+
response.errorData = LootLockerJson.DeserializeObject<LootLockerErrorData>(webRequest.downloadHandler.text);
137+
}
138+
catch (Exception)
139+
{
140+
if (webRequest.downloadHandler.text.StartsWith("<"))
141+
{
142+
LootLockerLogger.GetForLogLevel(LootLockerLogger.LogLevel.Warning)("JSON Starts with <, info: \n statusCode: " + response.statusCode + "\n body: " + response.text);
143+
}
144+
response.errorData = null;
145+
}
136146
// Error data was not parseable, populate with what we know
137147
if (response.errorData == null)
138148
{
@@ -332,7 +342,7 @@ private void RefreshTokenAndCompleteCall(LootLockerServerRequest cachedRequest,
332342
private static bool ShouldRefreshUsingRefreshToken(LootLockerServerRequest cachedRequest)
333343
{
334344
// The failed request isn't a refresh session request but we have a refresh token stored, so try to refresh the session automatically before failing
335-
return !cachedRequest.jsonPayload.Contains("refresh_token") && !string.IsNullOrEmpty(LootLockerConfig.current.refreshToken);
345+
return (string.IsNullOrEmpty(cachedRequest.jsonPayload) || !cachedRequest.jsonPayload.Contains("refresh_token")) && !string.IsNullOrEmpty(LootLockerConfig.current.refreshToken);
336346
}
337347

338348
private void CompleteCall(LootLockerServerRequest cachedRequest, LootLockerSessionResponse sessionRefreshResponse, Action<LootLockerResponse> onComplete)
@@ -480,4 +490,3 @@ private string GetQueryStringFromDictionary(Dictionary<string, string> queryDict
480490
#endregion
481491
}
482492
}
483-

Runtime/Client/LootLockerServerRequest.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ public static T Deserialize<T>(LootLockerResponse serverResponse,
239239
return new T() { success = false, errorData = serverResponse.errorData, statusCode = serverResponse.statusCode, text = serverResponse.text };
240240
}
241241

242+
/*
243+
* Turborilla:
244+
* Patched based on conversation with LootLocker. I suspect that some users are getting login pages for wifi or something else instead of the intended response from LootLocker servers.
245+
* We have similar checks in our other projects.
246+
*/
247+
if (serverResponse.text.StartsWith("<"))
248+
{
249+
LootLockerLogger.GetForLogLevel()("JSON Starts with <, info: \n statusCode: " + serverResponse.statusCode + "\n body: " + serverResponse.text);
250+
return new T() { success = false, errorData = serverResponse.errorData, statusCode = serverResponse.statusCode };
251+
}
242252
var response = LootLockerJson.DeserializeObject<T>(serverResponse.text, options ?? LootLockerJsonSettings.Default) ?? new T();
243253

244254
response.text = serverResponse.text;
@@ -708,4 +718,4 @@ public void Send(System.Action<LootLockerResponse> OnServerResponse)
708718
LootLockerServerApi.SendRequest(this, (response) => { OnServerResponse?.Invoke(response); });
709719
}
710720
}
711-
}
721+
}

Runtime/Game/LootLockerObfuscator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,4 @@ public static string ObfuscateJsonStringForLogging(string json)
179179
#endif //LOOTLOCKER_USE_NEWTONSOFTJSON
180180
}
181181
}
182-
}
182+
}

0 commit comments

Comments
 (0)