From 85e303ec54cd60b75f6b3cc4d0a457caafda4afc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 Nov 2023 20:00:09 +0900 Subject: [PATCH] Add two factor step to api state flow --- osu.Game/Online/API/APIAccess.cs | 5 +++++ osu.Game/Online/API/DummyAPIAccess.cs | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index 4f586c8fff..a3ceb14a40 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -540,6 +540,11 @@ namespace osu.Game.Online.API /// Failing, + /// + /// Waiting on second factor authentication. + /// + RequiresAuthentication, + /// /// We are in the process of (re-)connecting. /// diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index d585124db6..4cf2152193 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -55,6 +55,7 @@ namespace osu.Game.Online.API private bool shouldFailNextLogin; private bool stayConnectingNextLogin; + private bool requiresTwoFactor; /// /// The current connectivity state of the API. @@ -115,7 +116,13 @@ namespace osu.Game.Online.API Id = DUMMY_USER_ID, }; - state.Value = APIState.Online; + if (requiresTwoFactor) + { + state.Value = APIState.RequiresAuthentication; + requiresTwoFactor = false; + } + else + state.Value = APIState.Online; } public void Logout() @@ -142,6 +149,8 @@ namespace osu.Game.Online.API IBindableList IAPIProvider.Friends => Friends; IBindable IAPIProvider.Activity => Activity; + public void RequireTwoFactor() => requiresTwoFactor = true; + /// /// During the next simulated login, the process will fail immediately. ///