1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 10:03:21 +08:00

Dispose IDisposable object before method returns

This commit is contained in:
TocoToucan 2017-09-16 15:10:24 +03:00
parent 218a5f8097
commit 51a5e963bb

View File

@ -27,14 +27,14 @@ 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 try
{ {
req.BlockingPerform(); req.BlockingPerform();
@ -47,23 +47,26 @@ namespace osu.Game.Online.API
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
{ {
//todo: potentially only kill the refresh token on certain exception types. //todo: potentially only kill the refresh token on certain exception types.