/// <summary> /// </summary> private void OpenLoginScreen(object sender, EventArgs e) { IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell)); Guid clsid = Guid.Empty; OsbideLoginViewModel vm = new OsbideLoginViewModel(); vm.RequestCreateAccount += ShowCreateAccountTool; //attempt to store previously cached values if possible vm.Password = _userPassword; vm.Email = _userName; vm.IsLoggedIn = _client.IsSendingData; MessageBoxResult result = OsbideLoginControl.ShowModalDialog(vm); //assume that data was changed and needs to be saved if (result == MessageBoxResult.OK) { try { _cache[StringConstants.UserNameCacheKey] = vm.Email; _userName = vm.Email; _userPassword = vm.Password; _cache[StringConstants.PasswordCacheKey] = AesEncryption.EncryptStringToBytes_Aes(vm.Password, _encoder.Key, _encoder.IV); _cache[StringConstants.AuthenticationCacheKey] = vm.AuthenticationHash; } catch (Exception ex) { //write to the log file _errorLogger.WriteToLog(string.Format("SaveUser error: {0}", ex.Message), LogPriority.HighPriority); //turn off client sending if we run into an error if (_client != null) { _client.StopSending(); } } //If we got back a valid user, turn on log saving if (_userName != null && _userPassword != null) { //turn on client sending if (_client != null) { _client.IsCollectingData = true; _client.StartSending(); } MessageBox.Show("Welcome to OSBIDE!"); } else { //turn off client sending if the user didn't log in. if (_client != null) { _client.StopSending(); } } } else if (result == MessageBoxResult.No) { //In this case, I'm using MessageBoxResult.No to represent a log out request. We can //fake that by just turning off client collection and sending. _client.IsCollectingData = false; _client.StopSending(); _cache[StringConstants.AuthenticationCacheKey] = ""; MessageBox.Show("You have been logged out of OSBIDE."); } }
private void OpenLoginScreen(object sender, EventArgs e) { var vm = new OsbleLoginViewModel(); vm.RequestCreateAccount += ShowCreateAccountTool; //attempt to store previously cached values if possible vm.Password = _userPassword; vm.Email = _userName; vm.IsLoggedIn = _client.IsSendingData; var result = OsbideLoginControl.ShowModalDialog(vm); //assume that data was changed and needs to be saved if (result == MessageBoxResult.OK) { try { _cache[StringConstants.UserNameCacheKey] = vm.Email; _userName = vm.Email; _userPassword = vm.Password; _cache[StringConstants.PasswordCacheKey] = AesEncryption.EncryptStringToBytes_Aes(vm.Password, _encoder.Key, _encoder.IV); _cache[StringConstants.AuthenticationCacheKey] = vm.AuthenticationHash; } catch (Exception ex) { //write to the log file _errorLogger.WriteToLog(string.Format("SaveUser error: {0}", ex.Message), LogPriority.HighPriority); //turn off client sending if we run into an error if (_client != null) { _client.StopSending(); } } //If we got back a valid user, turn on log saving if (_userName != null && _userPassword != null) { //turn on client sending if (_client != null) { _client.IsCollectingData = true; _client.StartSending(); } MessageBox.Show("Welcome to OSBLE+!"); _manager.OpenActivityFeedWindow(); } else { //turn off client sending if the user didn't log in. if (_client != null) { _client.StopSending(); } } } else if (result == MessageBoxResult.No) { //In this case, I'm using MessageBoxResult.No to represent a log out request. We can //fake that by just turning off client collection and sending. _client.IsCollectingData = false; _client.StopSending(); _cache.Remove(StringConstants.AuthenticationCacheKey); //We need to clear the awesomium caches...? _manager.OpenActivityFeedWindow(null, StringConstants.WebClientRoot + "/Account/LogOff"); _manager.CloseActivityFeedWindow(); //redirect the feed url after we've logged out _manager.RedirectActivityFeedWindow(StringConstants.WebClientRoot + "/feed/osbide/"); _manager.CloseProfileWindow(); if (_cache.Contains("community") && Boolean.Equals(true, _cache["community"])) { _manager.CloseCommunityWindow(); } _manager.CloseInterventionWindow(); MessageBox.Show("You have been logged out of OSBLE+."); } }