1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 10:17:19 +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) internal bool AuthenticateWithLogin(string username, string password)
{ {
var req = new AccessTokenRequestPassword(username, password) using (var req = new AccessTokenRequestPassword(username, password)
{ {
Url = $@"{endpoint}/oauth/token", Url = $@"{endpoint}/oauth/token",
Method = HttpMethod.POST, Method = HttpMethod.POST,
ClientId = clientId, ClientId = clientId,
ClientSecret = clientSecret ClientSecret = clientSecret
}; })
try
{ {
req.BlockingPerform(); try
} {
catch req.BlockingPerform();
{ }
return false; catch
} {
return false;
}
Token = req.ResponseObject; Token = req.ResponseObject;
return true; return true;
}
} }
internal bool AuthenticateWithRefresh(string refresh) internal bool AuthenticateWithRefresh(string refresh)
{ {
try try
{ {
var req = new AccessTokenRequestRefresh(refresh) using (var req = new AccessTokenRequestRefresh(refresh)
{ {
Url = $@"{endpoint}/oauth/token", Url = $@"{endpoint}/oauth/token",
Method = HttpMethod.POST, Method = HttpMethod.POST,
ClientId = clientId, ClientId = clientId,
ClientSecret = clientSecret ClientSecret = clientSecret
}; })
req.BlockingPerform(); {
req.BlockingPerform();
Token = req.ResponseObject; Token = req.ResponseObject;
return true; return true;
}
} }
catch catch
{ {