1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:12:56 +08:00

Fix APIAccess spamming requests while waiting for second factor

This commit is contained in:
Bartłomiej Dach 2024-01-29 09:13:44 +01:00
parent 363fd1d54f
commit 96811a8874
No known key found for this signature in database

View File

@ -269,42 +269,44 @@ namespace osu.Game.Online.API
}
}
var userReq = new GetMeRequest();
userReq.Failure += ex =>
if (state.Value != APIState.RequiresSecondFactorAuth)
{
if (ex is APIException)
var userReq = new GetMeRequest();
userReq.Failure += ex =>
{
LastLoginError = ex;
log.Add($@"Login failed for username {ProvidedUsername} on user retrieval ({LastLoginError.Message})!");
Logout();
}
else if (ex is WebException webException && webException.Message == @"Unauthorized")
if (ex is APIException)
{
LastLoginError = ex;
log.Add($@"Login failed for username {ProvidedUsername} on user retrieval ({LastLoginError.Message})!");
Logout();
}
else if (ex is WebException webException && webException.Message == @"Unauthorized")
{
log.Add(@"Login no longer valid");
Logout();
}
else
{
state.Value = APIState.Failing;
}
};
userReq.Success += me =>
{
log.Add(@"Login no longer valid");
Logout();
}
else
me.Status.Value = configStatus.Value ?? UserStatus.Online;
setLocalUser(me);
state.Value = me.SessionVerified ? APIState.Online : APIState.RequiresSecondFactorAuth;
failureCount = 0;
};
if (!handleRequest(userReq))
{
state.Value = APIState.Failing;
return;
}
};
userReq.Success += me =>
{
me.Status.Value = configStatus.Value ?? UserStatus.Online;
setLocalUser(me);
state.Value = me.SessionVerified ? APIState.Online : APIState.RequiresSecondFactorAuth;
failureCount = 0;
};
if (!handleRequest(userReq))
{
state.Value = APIState.Failing;
return;
}
if (state.Value == APIState.RequiresSecondFactorAuth)
else
{
if (string.IsNullOrEmpty(SecondFactorCode))
return;