1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Merge pull request #26837 from bdach/2fa-not-verifying-via-link

Fix 2FA verification via link not working correctly
This commit is contained in:
Dean Herbert 2024-01-31 19:15:33 +09:00 committed by GitHub
commit 56700d672b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View File

@ -29,14 +29,11 @@ namespace osu.Game.Online.Notifications.WebSocket
protected override async Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken)
{
var tcs = new TaskCompletionSource<string>();
var req = new GetNotificationsRequest();
req.Success += bundle => tcs.SetResult(bundle.Endpoint);
req.Failure += ex => tcs.SetException(ex);
api.Queue(req);
string endpoint = await tcs.Task.ConfigureAwait(false);
// must use `PerformAsync()`, since we may not be fully online yet
// (see `APIState.RequiresSecondFactorAuth` - in this state queued requests will not execute).
await api.PerformAsync(req).ConfigureAwait(false);
string endpoint = req.Response!.Endpoint;
ClientWebSocket socket = new ClientWebSocket();
socket.Options.SetRequestHeader(@"Authorization", @$"Bearer {api.AccessToken}");

View File

@ -69,6 +69,7 @@ namespace osu.Game.Online
break;
case APIState.Online:
case APIState.RequiresSecondFactorAuth:
await connect().ConfigureAwait(true);
break;
}
@ -83,7 +84,7 @@ namespace osu.Game.Online
try
{
while (apiState.Value == APIState.Online)
while (apiState.Value == APIState.RequiresSecondFactorAuth || apiState.Value == APIState.Online)
{
// ensure any previous connection was disposed.
// this will also create a new cancellation token source.