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

Merge pull request #1281 from UselessToucan/DisposeIDisposableBeforeMethodReturns

Dispose IDisposable object before method returns
This commit is contained in:
Dean Herbert 2017-09-16 21:49:21 +09:00 committed by GitHub
commit 7f18990582

View File

@ -27,14 +27,14 @@ namespace osu.Game.Online.API
internal bool AuthenticateWithLogin(string username, string password)
{
var req = new AccessTokenRequestPassword(username, password)
using (var req = new AccessTokenRequestPassword(username, password)
{
Url = $@"{endpoint}/oauth/token",
Method = HttpMethod.POST,
ClientId = clientId,
ClientSecret = clientSecret
};
})
{
try
{
req.BlockingPerform();
@ -47,23 +47,26 @@ namespace osu.Game.Online.API
Token = req.ResponseObject;
return true;
}
}
internal bool AuthenticateWithRefresh(string refresh)
{
try
{
var req = new AccessTokenRequestRefresh(refresh)
using (var req = new AccessTokenRequestRefresh(refresh)
{
Url = $@"{endpoint}/oauth/token",
Method = HttpMethod.POST,
ClientId = clientId,
ClientSecret = clientSecret
};
})
{
req.BlockingPerform();
Token = req.ResponseObject;
return true;
}
}
catch
{
//todo: potentially only kill the refresh token on certain exception types.