mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 00:22:58 +08:00
Fix 2FA verification via link not working correctly
Closes https://github.com/ppy/osu/issues/26835. I must have not re-tested this correctly after all the refactors... Basically the issue is that the websocket connection would only come online when the API state changed to full `Online`. In particular the connector would not attempt to connect when the API state was `RequiresSecondFactorAuth`, giving the link-based flow no chance to actually work. The change in `WebSocketNotificationsClientConnector` is relevant in that queueing requests does nothing before the API state changes to full `Online`. It also cleans up things a bit code-wise so... win? And yes, this means that the _other_ `PersistentEndpointClientConnector` implementations (i.e. SignalR connectors) will also come online earlier after this. Based on previous discussions (https://github.com/ppy/osu/pull/25480#discussion_r1395566545) I think this is fine, but if it is _not_ fine, then it can be fixed by exposing a virtual that lets a connector to decide when to come alive, I guess.
This commit is contained in:
parent
6931af664e
commit
4126dcbe28
@ -29,14 +29,11 @@ namespace osu.Game.Online.Notifications.WebSocket
|
|||||||
|
|
||||||
protected override async Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
protected override async Task<PersistentEndpointClient> BuildConnectionAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var tcs = new TaskCompletionSource<string>();
|
|
||||||
|
|
||||||
var req = new GetNotificationsRequest();
|
var req = new GetNotificationsRequest();
|
||||||
req.Success += bundle => tcs.SetResult(bundle.Endpoint);
|
// must use `PerformAsync()`, since we may not be fully online yet
|
||||||
req.Failure += ex => tcs.SetException(ex);
|
// (see `APIState.RequiresSecondFactorAuth` - in this state queued requests will not execute).
|
||||||
api.Queue(req);
|
await api.PerformAsync(req).ConfigureAwait(false);
|
||||||
|
string endpoint = req.Response!.Endpoint;
|
||||||
string endpoint = await tcs.Task.ConfigureAwait(false);
|
|
||||||
|
|
||||||
ClientWebSocket socket = new ClientWebSocket();
|
ClientWebSocket socket = new ClientWebSocket();
|
||||||
socket.Options.SetRequestHeader(@"Authorization", @$"Bearer {api.AccessToken}");
|
socket.Options.SetRequestHeader(@"Authorization", @$"Bearer {api.AccessToken}");
|
||||||
|
@ -69,6 +69,7 @@ namespace osu.Game.Online
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case APIState.Online:
|
case APIState.Online:
|
||||||
|
case APIState.RequiresSecondFactorAuth:
|
||||||
await connect().ConfigureAwait(true);
|
await connect().ConfigureAwait(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -83,7 +84,7 @@ namespace osu.Game.Online
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (apiState.Value == APIState.Online)
|
while (apiState.Value == APIState.RequiresSecondFactorAuth || apiState.Value == APIState.Online)
|
||||||
{
|
{
|
||||||
// ensure any previous connection was disposed.
|
// ensure any previous connection was disposed.
|
||||||
// this will also create a new cancellation token source.
|
// this will also create a new cancellation token source.
|
||||||
|
Loading…
Reference in New Issue
Block a user