private async void webBrowser2_Navigated(object sender, WebBrowserNavigatedEventArgs e) { if (e.Url.AbsoluteUri == LoginUrl) { return; } if ((e.Url.AbsoluteUri.Contains("/Identity/Account/Logout"))) { //maybe we are logged in now GetCookieContainer(); } else if (e.Url.AbsoluteUri.Contains("/Identity/Account/Manage")) { try { //we are logged in! GetCookieContainer(); var client = StaticUtils.GetClient(); if (client == null) { Log.Error("Cloud not create an instance of SINnersclient!"); return; } var user = await client.GetUserByAuthorizationWithHttpMessagesAsync(); if (user.Body?.CallSuccess == true) { if (user.Body != null) { login = true; SINnerVisibility tempvis; if (!String.IsNullOrEmpty(Properties.Settings.Default.SINnerVisibility)) { tempvis = JsonConvert.DeserializeObject <SINnerVisibility>(Properties.Settings.Default.SINnerVisibility); } else { tempvis = new SINnerVisibility() { IsGroupVisible = true, IsPublic = true }; } tempvis.AddVisibilityForEmail(user.Body.MyApplicationUser?.Email); this.Close(); } else { login = false; } } } catch (Exception exception) { Log.Error(exception); throw; } } }
private void bVisibilityAddEmail_Click(object sender, EventArgs e) { string email = this.tbVisibilityAddEmail.Text; AddVisibilityForEmail(email); //Save it! SINnerVisibility.Save(clbVisibilityToUsers); }
public ucSINnerVisibility() { InitializeComponent(); MyVisibility = new SINnerVisibility() { UserRights = new List <SINerUserRight>() }; this.clbVisibilityToUsers.ItemCheck += clbVisibilityToUsers_ItemCheck; }
private async void webBrowser2_Navigated(object sender, WebBrowserNavigatedEventArgs e) { if (e.Url.AbsoluteUri == LoginUrl.AbsoluteUri) { return; } if ((e.Url.AbsoluteUri.Contains("/Identity/Account/Logout"))) { //maybe we are logged in now GetCookieContainer(); } else if (e.Url.AbsoluteUri.Contains("/Identity/Account/Manage")) { try { //we are logged in! SinnersClient client = GetCookieContainer(); if (client == null) { Log.Error("Cloud not create an instance of SINnersclient!"); login = false; return; } ResultAccountGetUserByAuthorization body = await client.GetUserByAuthorizationAsync().ConfigureAwait(false); if (body?.CallSuccess == true) { login = true; Program.MainForm.Invoke(new Action(() => { SINnerVisibility tempvis = Backend.Utils.DefaultSINnerVisibility ?? new SINnerVisibility { IsGroupVisible = true, IsPublic = true }; tempvis.AddVisibilityForEmail(body.MyApplicationUser?.Email); Close(); })); } else { login = false; } } catch (ApiException ae) { Log.Info(ae); throw; } catch (Exception exception) { Log.Error(exception); throw; } } }
public ucSINnerVisibility(SINnerVisibility vis) { MyVisibility = vis; InitializeComponent(); if (MyVisibility?.IsGroupVisible.HasValue == true) { this.cbVisibleInGroups.Checked = MyVisibility.IsGroupVisible.Value; } else { this.cbVisibleInGroups.Checked = true; } this.clbVisibilityToUsers.ItemCheck += clbVisibilityToUsers_ItemCheck; }
private void bVisibilityRemove_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(clbVisibilityToUsers); selectedItems = clbVisibilityToUsers.SelectedItems; if (clbVisibilityToUsers.SelectedIndex != -1) { for (int i = selectedItems.Count - 1; i >= 0; i--) { var userright = selectedItems[i] as SINerUserRight; SINnersOptions.SINnerVisibility.UserRightsObservable.Remove(userright); } //Save it! SINnerVisibility.Save(clbVisibilityToUsers); } else { MessageBox.Show("No email selected!"); } }
public ucSINnerVisibility(SINnerVisibility vis) { MyVisibility = vis; InitializeComponent(); this.clbVisibilityToUsers.ItemCheck += clbVisibilityToUsers_ItemCheck; }
private void OptionsUpdate() { SINnersOptions.SINnerVisibility.IsPublic = this.cbVisibilityIsPublic.Checked; SINnersOptions.SINnerVisibility.IsGroupVisible = this.cbVisibilityIsGroupVisible.Checked; SINnerVisibility.Save(this.clbVisibilityToUsers); }
public async void UpdateDisplay() { PluginHandler.MainForm.DoThreadSafe(new Action(() => { try { if (LoginStatus == true) { var t = GetUserEmail(); t.ContinueWith((emailtask) => { string mail = emailtask.Result; if (!String.IsNullOrEmpty(mail)) { Properties.Settings.Default.UserEmail = mail; bool createVis = false; if (String.IsNullOrEmpty(Properties.Settings.Default.SINnerVisibility)) { createVis = true; } else { SINnerVisibility vis = Newtonsoft.Json.JsonConvert.DeserializeObject <SINnerVisibility>(Properties.Settings.Default.SINnerVisibility); bool found = false; foreach (var ur in vis.UserRights) { if (ur.EMail.ToLowerInvariant() == mail.ToLowerInvariant()) { ur.CanEdit = true; found = true; break; } } if (!found) { createVis = true; } } if (createVis) { SINnerVisibility vis = new SINnerVisibility(); vis.Id = Guid.NewGuid(); vis.IsGroupVisible = true; vis.IsPublic = true; vis.UserRights = new List <SINerUserRight>(); SINerUserRight ur = new SINerUserRight(); ur.Id = Guid.NewGuid(); ur.EMail = mail; ur.CanEdit = true; vis.UserRights.Add(ur); SINnersOptions.SINnerVisibility = null; SINnersOptions.SINnerVisibility = vis; Properties.Settings.Default.SINnerVisibility = Newtonsoft.Json.JsonConvert.SerializeObject(vis); Properties.Settings.Default.Save(); FillVisibilityListBox(); } //also, since we are logged in in now, refresh the frmCharacterRoster! PluginHandler.MainForm.DoThreadSafe(() => { PluginHandler.MainForm.CharacterRoster.LoadCharacters(true, true, true, true); }); } }); this.bLogin.Text = "Logout"; string status = StaticUtils.UserRoles.Aggregate((a, b) => a + ", " + b); labelAccountStatus.Text = status; labelAccountStatus.ForeColor = Color.DarkGreen; HideWebBrowser(); } else if (LoginStatus == false) { this.bLogin.Text = "Login"; this.labelAccountStatus.Text = "logged out"; this.labelAccountStatus.ForeColor = Color.DarkRed; } else { this.bLogin.Text = "Login"; this.labelAccountStatus.Text = "unknown"; this.labelAccountStatus.ForeColor = Color.DeepPink; } } catch (Exception ex) { System.Diagnostics.Trace.TraceError(ex.ToString()); } })); }
public async void UpdateDisplay() { PluginHandler.MainForm.DoThreadSafe(new Action(() => { try { if (LoginStatus == true) { if (String.IsNullOrEmpty(Properties.Settings.Default.UserEmail)) { var t = GetUserEmail(); t.ContinueWith((emailtask) => { string mail = emailtask.Result; if (!String.IsNullOrEmpty(mail)) { Properties.Settings.Default.UserEmail = mail; if (String.IsNullOrEmpty(Properties.Settings.Default.SINnerVisibility)) { SINnerVisibility vis = new SINnerVisibility(); vis.Id = Guid.NewGuid(); vis.Groupname = "ChangeThis!"; vis.IsGroupVisible = true; vis.IsPublic = true; vis.UserRights = new List <SINerUserRight>(); SINerUserRight ur = new SINerUserRight(); ur.Id = Guid.NewGuid(); ur.EMail = mail; ur.CanEdit = true; vis.UserRights.Add(ur); Properties.Settings.Default.SINnerVisibility = Newtonsoft.Json.JsonConvert.SerializeObject(vis); Properties.Settings.Default.Save(); } } }); } this.bLogin.Text = "Logout"; string status = Roles.Aggregate((a, b) => a + ", " + b); labelAccountStatus.Text = status; labelAccountStatus.ForeColor = Color.DarkGreen; HideWebBrowser(); } else if (LoginStatus == false) { this.bLogin.Text = "Login"; this.labelAccountStatus.Text = "logged out"; this.labelAccountStatus.ForeColor = Color.DarkRed; } else { this.bLogin.Text = "Login"; this.labelAccountStatus.Text = "unknown"; this.labelAccountStatus.ForeColor = Color.DeepPink; } } catch (Exception ex) { System.Diagnostics.Trace.TraceError(ex.ToString()); } })); }
private async void webBrowser2_Navigated(object sender, WebBrowserNavigatedEventArgs e) { if (e.Url.AbsoluteUri == LoginUrl.AbsoluteUri) { return; } if ((e.Url.AbsoluteUri.Contains("/Identity/Account/Logout"))) { //maybe we are logged in now GetCookieContainer(); } else if (e.Url.AbsoluteUri.Contains("/Identity/Account/Manage")) { try { //we are logged in! GetCookieContainer(); var client = StaticUtils.GetClient(); if (client == null) { Log.Error("Cloud not create an instance of SINnersclient!"); return; } //var body = client.GetUserByAuthorizationAsync().Result; var body = await client.GetUserByAuthorizationAsync().ConfigureAwait(false); { if (body?.CallSuccess == true) { login = true; Program.MainForm.Invoke(new Action(() => { SINnerVisibility tempvis; if (!string.IsNullOrEmpty(Settings.Default.SINnerVisibility)) { tempvis = JsonConvert.DeserializeObject <SINnerVisibility>(Settings.Default.SINnerVisibility); } else { tempvis = new SINnerVisibility { IsGroupVisible = true, IsPublic = true }; } tempvis.AddVisibilityForEmail(body.MyApplicationUser?.Email); Close(); })); } else { login = false; } } } catch (Exception exception) { Log.Error(exception); throw; } } }