mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +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,19 +128,12 @@ namespace osu.Game.Online.API
|
|||||||
// if we already have a valid access token, let's use it.
|
// if we already have a valid access token, let's use it.
|
||||||
if (accessTokenValid) return true;
|
if (accessTokenValid) return true;
|
||||||
|
|
||||||
// we want to ensure only a single authentication update is happening at once.
|
// if not, let's try using our refresh token to request a new access token.
|
||||||
lock (access_token_retrieval_lock)
|
if (!string.IsNullOrEmpty(Token.Value?.RefreshToken))
|
||||||
{
|
// ReSharper disable once PossibleNullReferenceException
|
||||||
// re-check if valid, in case another request completed and revalidated our access.
|
AuthenticateWithRefresh(Token.Value.RefreshToken);
|
||||||
if (accessTokenValid) return true;
|
|
||||||
|
|
||||||
// if not, let's try using our refresh token to request a new access token.
|
return accessTokenValid;
|
||||||
if (!string.IsNullOrEmpty(Token.Value?.RefreshToken))
|
|
||||||
// ReSharper disable once PossibleNullReferenceException
|
|
||||||
AuthenticateWithRefresh(Token.Value.RefreshToken);
|
|
||||||
|
|
||||||
return accessTokenValid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool accessTokenValid => Token.Value?.IsValid ?? false;
|
private bool accessTokenValid => Token.Value?.IsValid ?? false;
|
||||||
@ -149,14 +142,18 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
internal string RequestAccessToken()
|
internal string RequestAccessToken()
|
||||||
{
|
{
|
||||||
if (!ensureAccessToken()) return null;
|
lock (access_token_retrieval_lock)
|
||||||
|
{
|
||||||
|
if (!ensureAccessToken()) return null;
|
||||||
|
|
||||||
return Token.Value.AccessToken;
|
return Token.Value.AccessToken;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Clear()
|
internal void Clear()
|
||||||
{
|
{
|
||||||
Token.Value = null;
|
lock (access_token_retrieval_lock)
|
||||||
|
Token.Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AccessTokenRequestRefresh : AccessTokenRequest
|
private class AccessTokenRequestRefresh : AccessTokenRequest
|
||||||
|
Loading…
Reference in New Issue
Block a user