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

Merge pull request #26834 from bdach/2fa-cancel-crash

Fix crash when logging out during 2FA email verification
This commit is contained in:
Dean Herbert 2024-01-31 18:32:33 +09:00 committed by GitHub
commit edab05672b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,12 +128,6 @@ namespace osu.Game.Online.API
// if we already have a valid access token, let's use it.
if (accessTokenValid) return true;
// we want to ensure only a single authentication update is happening at once.
lock (access_token_retrieval_lock)
{
// re-check if valid, in case another request completed and revalidated our access.
if (accessTokenValid) return true;
// if not, let's try using our refresh token to request a new access token.
if (!string.IsNullOrEmpty(Token.Value?.RefreshToken))
// ReSharper disable once PossibleNullReferenceException
@ -141,21 +135,24 @@ namespace osu.Game.Online.API
return accessTokenValid;
}
}
private bool accessTokenValid => Token.Value?.IsValid ?? false;
internal bool HasValidAccessToken => RequestAccessToken() != null;
internal string RequestAccessToken()
{
lock (access_token_retrieval_lock)
{
if (!ensureAccessToken()) return null;
return Token.Value.AccessToken;
}
}
internal void Clear()
{
lock (access_token_retrieval_lock)
Token.Value = null;
}