1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 03:57:24 +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,42 +27,45 @@ 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();
}
catch
{
return false;
}
try
{
req.BlockingPerform();
}
catch
{
return false;
}
Token = req.ResponseObject;
return true;
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();
})
{
req.BlockingPerform();
Token = req.ResponseObject;
return true;
Token = req.ResponseObject;
return true;
}
}
catch
{