From 17168b8137bc3c68e4f35df75af2f51d2d73cc1f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Jul 2021 18:58:22 +0900 Subject: [PATCH] Fix authentication loss not handled correctly This handles the case where on initial API connection, the server responds with an `Unauthorized` response. It doesn't perform this same checking/handling on every API request, which is probably what we want eventually. Opting to not address the full issue because I know this is going to be a long one (see https://github.com/ppy/osu/blob/05c50c0f6cfafab359963586ec265ad4f143a46c/osu.Game/Online/API/APIAccess.cs#L233). --- osu.Game/Online/API/APIAccess.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 1686595512..eb3abff2b7 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -148,6 +148,16 @@ namespace osu.Game.Online.API var userReq = new GetUserRequest(); + userReq.Failure += ex => + { + if (ex.InnerException is WebException webException && webException.Message == @"Unauthorized") + { + log.Add(@"Login no longer valid"); + Logout(); + } + else + failConnectionProcess(); + }; userReq.Success += u => { localUser.Value = u; @@ -167,6 +177,7 @@ namespace osu.Game.Online.API // getting user's friends is considered part of the connection process. var friendsReq = new GetFriendsRequest(); + friendsReq.Failure += _ => failConnectionProcess(); friendsReq.Success += res => { friends.AddRange(res);