protected virtual async void AuthHttpServer_AuthorizationFinished(object sender, AuthEventArgs e) { this.AuthHttpServer.AuthorizationFinished -= this.AuthHttpServer_AuthorizationFinished; await this.AuthHttpServer.Stop().ConfigureAwait(false); this.authResponse = e; }
private void authBtnDelete_Click(object sender, AuthEventArgs e) { if (!e.OK) { } if (_selectedNode == null) { return; } Function f = _selectedNode.Tag as Function; if (f == null) { return; } //从数据库删除这个FuncitonID=_selectedFunID的记录 bool ok = _funLogic.DeleteFuncitonByID(f.FunctionID); if (ok) { tvFunction.Nodes.Remove(_selectedNode); MessageBox.Show("删除成功"); } else { MessageBox.Show("删除失败"); } }
private void EnterButton_Click(object sender, EventArgs e) { if (UserIdField.Text == "") { MessageBox.Show("ユーザー名を入力してください"); UserIdField.Focus(); return; } else if (PasswordField.Text == "") { MessageBox.Show("パスワードを入力してください"); PasswordField.Focus(); return; } AuthEventArgs e2 = new AuthEventArgs(); e2.UserId = UserIdField.Text; e2.Password = PasswordField.Text; Auth(e2); if (!e2.Success) { MessageBox.Show("ユーザー名またはパスワードに誤りがあります"); UserIdField.Focus(); return; } DialogResult = System.Windows.Forms.DialogResult.OK; Close(); }
private async void AuthHttpServer_AuthorizationFinished(object sender, AuthEventArgs e) { this.AuthHttpServer.AuthorizationFinished -= this.AuthHttpServer_AuthorizationFinished; await this.AuthHttpServer.Stop(); this.authResponse = e; }
private void OnAuthEvent(AuthEventArgs args) { if (AuthEvent != null) { AuthEvent(this, args); } }
protected async Task Connect() { m_SessionStore = new FileSessionStore(); TcpClientConnectionHandler handler = null; if (ProxyType != ProxyType.None) { handler = ProxyHandler; } client = new TelegramClient(m_ApiID, m_ApiHash, m_SessionStore, m_PhoneNumber, handler: handler); await client.ConnectAsync(); if (!TestClient()) { var hash = await client.SendCodeRequestAsync(m_PhoneNumber); if (!String.IsNullOrEmpty(hash)) { var arg = new AuthEventArgs { hash = hash }; AuthCodeHandler?.Invoke(this, arg); await client.MakeAuthAsync(m_PhoneNumber, hash, arg.code); } } }
/// <summary> /// 编辑按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, AuthEventArgs e) { gbDetail.Enabled = true; pnlAction.Enabled = false; gbUser.Enabled = true; gbFunction.Enabled = true; }
private void HttpServerOnOnAuth(AuthEventArgs e) { OnResponseReceivedEvent?.Invoke(new AutorizationCodeAuthResponse() { Code = e.Code, State = e.State, Error = e.Error }); }
private void HttpServerOnOnAuth(AuthEventArgs e) { OnResponseReceivedEvent?.Invoke(new Token { AccessToken = e.Code, TokenType = e.TokenType, ExpiresIn = e.ExpiresIn, Error = e.Error }, e.State); }
private void HttpServerOnOnAuth(AuthEventArgs e) { OnResponseReceivedEvent?.Invoke(new Token { AccessToken = e.Code, TokenType = e.TokenType, ExpiresIn = e.ExpiresIn, Error = e.Error }, e.State); }
private void CommandDispatcherOnOnAuthOver(object sender, AuthEventArgs eventArgs) { MessageBox.Show(eventArgs.AuthResponse.Message); if (eventArgs.AuthResponse.Status == 200) { var asd = sender; var blf = new BlfPanel(); blf.Show(); } }
/// <summary> /// 添加按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, AuthEventArgs e) { if (!e.OK) { return; } _bAdd = true; txtDepName.Text = string.Empty; gbDetail.Enabled = true; //添加时解锁界面/启用界面 pnlAction.Enabled = false; //禁用动作面板 }
protected override void AuthHttpServer_AuthorizationFinished(object sender, AuthEventArgs e) { try { base.AuthHttpServer_AuthorizationFinished(sender, e); this.DisposeWebViewWindow(TimeSpan.FromSeconds(2)); } catch (Exception ex) { logger.Error($"Unhandled error in {nameof(this.AuthHttpServer_AuthorizationFinished)}", ex); } }
/// <summary> /// 添加按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, AuthEventArgs e) { if (!e.OK) { return; } _bAdd = true; txtName.Text = string.Empty; txtNote.Text = string.Empty; gbDetail.Enabled = true; pnlAction.Enabled = false; gbUser.Enabled = true; gbFunction.Enabled = true; }
private void btnEdit_Click(object sender, AuthEventArgs e) { if (_selectedNode == null) { return; } Department d = _selectedNode.Tag as Department; if (d == null) { return; } gbDetail.Enabled = true;//编辑时解锁界面/启用界面 pnlAction.Enabled = false; }
private void btnAdd_Click(object sender, AuthEventArgs e) { if (!e.OK) { return; } Debug.WriteLine("btnAdd_Click"); if (!e.OK) { return; } _bAdd = true; txtFunctionControl.Text = string.Empty; txtFunctionName.Text = string.Empty; gbDetail.Enabled = true; //添加时解锁界面/启用界面 pnlAction.Enabled = false; //禁用动作面板 }
private void CommandDispatcher_OnAuthOver(object sender, AuthEventArgs e) { Dispatcher.Invoke(() => { switch (e.AuthResponse.Status) { case 200: BlfNumberLabel.Background = new SolidColorBrush(Colors.Green); BlfStatusLabel.Background = new SolidColorBrush(Colors.Green); BlfStatusLabel.Text = e.AuthResponse.Status.ToString(); BlfNumberLabel.Text = "101"; break; case 401: BlfNumberLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Text = e.AuthResponse.Status.ToString(); BlfNumberLabel.Text = "101"; break; case 404: BlfNumberLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Text = e.AuthResponse.Status.ToString(); BlfNumberLabel.Text = "101"; break; case 408: BlfNumberLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Text = e.AuthResponse.Status.ToString(); BlfNumberLabel.Text = "101"; break; default: BlfNumberLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128)); BlfStatusLabel.Text = e.AuthResponse.Status.ToString(); BlfNumberLabel.Text = "101"; break; } }); CommandDispatcher.ContactsLoaded += CommandDispatcher_ContactsLoaded; CommandDispatcher.GetContacts("onBlf", true.ToString()); }
/// <summary> /// 添加按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, AuthEventArgs e) { if (!e.OK) { return; } _bAdd = true; txtName.Text = string.Empty; txtNote.Text = string.Empty; gbDetail.Enabled = true; pnlAction.Enabled = false; gbUser.Enabled = true; gbFunction.Enabled = true; //1.构造一个实例 //2.向数据库插入数据 //3.清除所有节点 //4.重新读取节点 }
void webBrowserAuthorization_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e) { //HideScriptErrors(webBrowserAuthorization, true); if (!initialLogoutCompleted) { initialLogoutCompleted = true; startAuthorization(); return; } else { if (e != null) { if (e.Url.AbsoluteUri.Contains("code=")) { complete = true; Model.Authentication.auth_response response = Authentications.parse_authentication_reponse(e.Url.AbsoluteUri); AuthEventArgs eventArgs = new AuthEventArgs(); if (response.success) { Model.Authentication.token token = Authentications.get_access_token(response.code, client_id, client_secret, redirect_uri); if (token != null) { eventArgs.success = true; eventArgs.token = token; } else { eventArgs.error = "Unable to retrieve access token from code"; } } else { eventArgs.error = response.error_message; } AuthSuccess(this, eventArgs); Close(); } } } }
/// <summary> /// 删除按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, AuthEventArgs e) { if (_selectedNode == null) { return; } Role r = _selectedNode.Tag as Role; if (r == null) { return; } bool ok = _rlLogic.DeleteRoleByID(r.RoleID); if (ok) { tvRole.Nodes.Remove(_selectedNode); } }
private void btnDelete_Click(object sender, AuthEventArgs e) { if (_selectedNode == null) { return; } Department d = _selectedNode.Tag as Department; if (d == null) { return; } bool ok = _depLogic.DeleteDepartmentByID(d.DepartmentID); if (ok) { tvDep.Nodes.Remove(_selectedNode); } txtDepName.Clear(); }
/// <summary> /// User change callback. Alters current Tray Menu /// </summary> /// <param name="e"></param> void OnAuthChange(AuthEventArgs e) { if (e.User != null) { if (e.User.IsAdmin) { TraySetForAdmin(); } else { TraySetForUser(); } } else { if (timerDisplay != null && !timerDisplay.IsDisposed) { timerDisplay.Hide(); timerDisplay.Dispose(); timerDisplay = null; } TraySetNoAuth(); } }
private void btnDelete_Click(object sender, AuthEventArgs e) { //有删除权限的情况,调用逻辑层真正删除 if (_selectedNode == null) { return; } Function f = _selectedNode.Tag as Function; if (f == null) { return; } //从数据库删除这个FuncitonID=_selectedFunID的记录 bool ok = _funLogic.DeleteFuncitonByID(f.FunctionID); if (ok) { txtFunctionName.Text = string.Empty; txtFunctionControl.Text = string.Empty; tvFunction.Nodes.Clear();//清除所有节点重新加载 InitFunctionTree(); } }
private void btnEdit_Click(object sender, AuthEventArgs e) { gbDetail.Enabled = true;//编辑时解锁界面/启用界面 pnlAction.Enabled = false; tvFunction.Enabled = false; }
void webBrowserAuthorization_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e) { if (!initialLogoutCompleted) { initialLogoutCompleted = true; startAuthorization(); return; } else { if (e != null) { if (e.Url.AbsoluteUri.Contains("code=")) { complete = true; Helper.Response response = Helper.SendGetRequest(e.Url.AbsoluteUri); AuthEventArgs eventArgs = new AuthEventArgs(); if (!string.IsNullOrEmpty(response.Content)) { if (!response.Content.StartsWith("ERROR:::")) { eventArgs.accessToken = response.Content; eventArgs.success = true; AuthSuccess(this, eventArgs); Close(); return; } else { eventArgs.error = response.Content.Substring(8); } } else { eventArgs.error = "Null response"; } AuthSuccess(this, eventArgs); Close(); } if (e.Url != null) { if (e.Url.AbsoluteUri.Contains("#access_token=")) { AuthEventArgs eventArgs = new AuthEventArgs(); complete = true; string regexParams = "#access_token=(.*?)[&|\\?]"; Regex regex = new Regex(regexParams); Match match = regex.Match(e.Url.AbsoluteUri); string accessToken = ""; if (match.Success) { accessToken = match.Groups[1].Value; eventArgs.success = true; eventArgs.accessToken = accessToken; eventArgs.error = ""; } else { eventArgs.error = "Parsing error on access token"; } AuthSuccess(this, eventArgs); Close(); } } } } }
void webBrowserAuthorization_Navigating(object sender, System.Windows.Forms.WebBrowserNavigatingEventArgs e) { return; if (!initialLogoutCompleted) { return; } if (e != null) { if (e.Url.AbsoluteUri.Contains("code=")) { complete = true; Model.Authentication.auth_response response = Authentications.parse_authentication_reponse(e.Url.AbsoluteUri); AuthEventArgs eventArgs = new AuthEventArgs(); if (response.success) { Model.Authentication.token token = Authentications.get_access_token(response.code, client_id, client_secret, redirect_uri); if (token != null) { eventArgs.success = true; eventArgs.token = token; } else { eventArgs.error = "Unable to retrieve access token from code"; } } else { eventArgs.error = response.error_message; } AuthSuccess(this, eventArgs); Close(); } } }
/* public AuthorizationWindow(string clientId, string redirectUrl, string scope, bool serverSide = true) { /* InitializeComponent(); Guid guid = System.Guid.NewGuid(); state = guid.ToString(); webBrowserAuthorization.Navigating += webBrowserAuthorization_Navigating; webBrowserAuthorization.Navigate("https://alpha.app.net/logout/"); webBrowserAuthorization.SourceUpdated += webBrowserAuthorization_SourceUpdated; authUrl = string.Format("https://alpha.app.net/oauth/authenticate?client_id={0}&response_type=code&redirect_uri={1}&scope={2}&state={3}", System.Web.HttpUtility.UrlEncode(clientId), System.Web.HttpUtility.UrlEncode(redirectUrl), System.Web.HttpUtility.UrlEncode(scope), System.Web.HttpUtility.UrlEncode(state)); * */ // } void webBrowserAuthorization_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e) { if (complete) { return; } WebBrowser browser = sender as WebBrowser; if (e != null && browser != null) { if(e.Uri.AbsoluteUri.Contains("code=")) { complete = true; e.Cancel = true; Helper.Response response = Helper.SendGetRequest(e.Uri.AbsoluteUri); AuthEventArgs eventArgs = new AuthEventArgs(); if (!string.IsNullOrEmpty(response.Content)) { if(!response.Content.StartsWith("ERROR:::")) { eventArgs.accessToken = response.Content; eventArgs.success = true; AuthSuccess(this, eventArgs); Close(); return; } else { eventArgs.error = response.Content.Substring(8); } } else { eventArgs.error = "Null response"; } AuthSuccess(this, eventArgs); Close(); } if (browser.Source != null && false) { if (browser.Source.Fragment.Contains("#access_token=")) { AuthEventArgs eventArgs = new AuthEventArgs(); complete = true; e.Cancel = true; string regexParams = "#access_token=([A-Za-z0-9]*)"; Regex regex = new Regex(regexParams); Match match = regex.Match(e.Uri.AbsoluteUri); string accessToken = ""; if (match.Success) { accessToken = match.Groups[1].Value; eventArgs.success = true; eventArgs.accessToken = accessToken; eventArgs.error = ""; } else { eventArgs.error = "Parsing error"; } AuthSuccess(this, eventArgs); Close(); } } } }
/* public AuthorizationWindow(string clientId, string redirectUrl, string scope, bool serverSide = true) * { /* * InitializeComponent(); * Guid guid = System.Guid.NewGuid(); * state = guid.ToString(); * webBrowserAuthorization.Navigating += webBrowserAuthorization_Navigating; * webBrowserAuthorization.Navigate("https://alpha.app.net/logout/"); * webBrowserAuthorization.SourceUpdated += webBrowserAuthorization_SourceUpdated; * authUrl = string.Format("https://alpha.app.net/oauth/authenticate?client_id={0}&response_type=code&redirect_uri={1}&scope={2}&state={3}", System.Web.HttpUtility.UrlEncode(clientId), System.Web.HttpUtility.UrlEncode(redirectUrl), System.Web.HttpUtility.UrlEncode(scope), System.Web.HttpUtility.UrlEncode(state)); * */ // } void webBrowserAuthorization_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e) { if (complete) { return; } WebBrowser browser = sender as WebBrowser; if (e != null && browser != null) { if (e.Uri.AbsoluteUri.Contains("code=")) { complete = true; e.Cancel = true; Helper.Response response = Helper.SendGetRequest(e.Uri.AbsoluteUri); AuthEventArgs eventArgs = new AuthEventArgs(); if (!string.IsNullOrEmpty(response.Content)) { if (!response.Content.StartsWith("ERROR:::")) { eventArgs.accessToken = response.Content; eventArgs.success = true; AuthSuccess(this, eventArgs); Close(); return; } else { eventArgs.error = response.Content.Substring(8); } } else { eventArgs.error = "Null response"; } AuthSuccess(this, eventArgs); Close(); } if (browser.Source != null && false) { if (browser.Source.Fragment.Contains("#access_token=")) { AuthEventArgs eventArgs = new AuthEventArgs(); complete = true; e.Cancel = true; string regexParams = "#access_token=([A-Za-z0-9]*)"; Regex regex = new Regex(regexParams); Match match = regex.Match(e.Uri.AbsoluteUri); string accessToken = ""; if (match.Success) { accessToken = match.Groups[1].Value; eventArgs.success = true; eventArgs.accessToken = accessToken; eventArgs.error = ""; } else { eventArgs.error = "Parsing error"; } AuthSuccess(this, eventArgs); Close(); } } } }
void webBrowserAuthorization_Navigated(object sender, System.Windows.Forms.WebBrowserNavigatedEventArgs e) { if (!initialLogoutCompleted) { initialLogoutCompleted = true; startAuthorization(); return; } else { if (e != null) { if (e.Url.AbsoluteUri.Contains("code=")) { complete = true; Helper.Response response = Helper.SendGetRequest(e.Url.AbsoluteUri); AuthEventArgs eventArgs = new AuthEventArgs(); if (!string.IsNullOrEmpty(response.Content)) { if (!response.Content.StartsWith("ERROR:::")) { eventArgs.accessToken = response.Content; eventArgs.success = true; AuthSuccess(this, eventArgs); Close(); return; } else { eventArgs.error = response.Content.Substring(8); } } else { eventArgs.error = "Null response"; } AuthSuccess(this, eventArgs); Close(); } if (e.Url != null) { if (e.Url.AbsoluteUri.Contains("#access_token=")) { AuthEventArgs eventArgs = new AuthEventArgs(); complete = true; string regexParams = "#access_token=(.*?)[&|\\?]"; Regex regex = new Regex(regexParams); Match match = regex.Match(e.Url.AbsoluteUri); string accessToken = ""; if (match.Success) { accessToken = match.Groups[1].Value; eventArgs.success = true; eventArgs.accessToken = accessToken; eventArgs.error = ""; } else { eventArgs.error = "Parsing error on access token"; } AuthSuccess(this, eventArgs); Close(); } } } } }
private void HttpServerOnOnAuth(AuthEventArgs e) { if (OnResponseReceivedEvent != null) OnResponseReceivedEvent(new AutorizationCodeAuthResponse() { Code = e.Code, State = e.State, Error = e.Error }); }