From 51a5e963bb80aff199e34df8ed5f1e96150746e2 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Sat, 16 Sep 2017 15:10:24 +0300 Subject: [PATCH] Dispose IDisposable object before method returns --- osu.Game/Online/API/OAuth.cs | 37 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/osu.Game/Online/API/OAuth.cs b/osu.Game/Online/API/OAuth.cs index c96b21a855..5410bcc55d 100644 --- a/osu.Game/Online/API/OAuth.cs +++ b/osu.Game/Online/API/OAuth.cs @@ -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 {