mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 19:13:21 +08:00
Fix APIAccess
spamming requests while waiting for second factor
This commit is contained in:
parent
363fd1d54f
commit
96811a8874
@ -269,42 +269,44 @@ namespace osu.Game.Online.API
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var userReq = new GetMeRequest();
|
if (state.Value != APIState.RequiresSecondFactorAuth)
|
||||||
userReq.Failure += ex =>
|
|
||||||
{
|
{
|
||||||
if (ex is APIException)
|
var userReq = new GetMeRequest();
|
||||||
|
userReq.Failure += ex =>
|
||||||
{
|
{
|
||||||
LastLoginError = ex;
|
if (ex is APIException)
|
||||||
log.Add($@"Login failed for username {ProvidedUsername} on user retrieval ({LastLoginError.Message})!");
|
{
|
||||||
Logout();
|
LastLoginError = ex;
|
||||||
}
|
log.Add($@"Login failed for username {ProvidedUsername} on user retrieval ({LastLoginError.Message})!");
|
||||||
else if (ex is WebException webException && webException.Message == @"Unauthorized")
|
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");
|
me.Status.Value = configStatus.Value ?? UserStatus.Online;
|
||||||
Logout();
|
|
||||||
}
|
setLocalUser(me);
|
||||||
else
|
|
||||||
|
state.Value = me.SessionVerified ? APIState.Online : APIState.RequiresSecondFactorAuth;
|
||||||
|
failureCount = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!handleRequest(userReq))
|
||||||
{
|
{
|
||||||
state.Value = APIState.Failing;
|
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;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (state.Value == APIState.RequiresSecondFactorAuth)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(SecondFactorCode))
|
if (string.IsNullOrEmpty(SecondFactorCode))
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user