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:
commit
edab05672b
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user