From c5d5c8bb8e9e9af77634e513d68c191ac7a6aedc Mon Sep 17 00:00:00 2001 From: Rennerdo30 Date: Fri, 3 May 2019 08:56:40 +0200 Subject: [PATCH] Fix for #52 --- src/GitLab.VisualStudio/Services/Storage.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/GitLab.VisualStudio/Services/Storage.cs b/src/GitLab.VisualStudio/Services/Storage.cs index 3527c49..dca3365 100644 --- a/src/GitLab.VisualStudio/Services/Storage.cs +++ b/src/GitLab.VisualStudio/Services/Storage.cs @@ -114,9 +114,9 @@ private void SaveUserToLocal(User user) System.IO.File.WriteAllText(_path, Newtonsoft.Json.JsonConvert.SerializeObject(user)); user.PrivateToken = pt; } - catch (Exception ) + catch (Exception) { - + } } @@ -144,11 +144,13 @@ private User LoadUser() try { var _path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), $"{new Uri(Host).Host}.gitlab4vs"); - if (System.IO.File.Exists(_path)) + if (!System.IO.File.Exists(_path)) { - _user = Newtonsoft.Json.JsonConvert.DeserializeObject(System.IO.File.ReadAllText(_path)); - _user.PrivateToken = GetToken(_user.Host); + _path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), $"{new Uri(Strings.DefaultHost).Host}.gitlab4vs"); } + + _user = Newtonsoft.Json.JsonConvert.DeserializeObject(System.IO.File.ReadAllText(_path)); + _user.PrivateToken = GetToken(_user.Host); } catch (Exception ex) { @@ -222,11 +224,11 @@ public bool HaveHost(string host) } result = HostVersionInfo.ContainsKey(host); - if (!result && Uri.TryCreate(host, UriKind.Absolute, out Uri uri)) + if (!result && Uri.TryCreate(host, UriKind.Absolute, out Uri uri)) { result = HostVersionInfo.ContainsKey(uri.Host); } - + return result; }