public void UserLogin(object loginDialog, UserLoginEventArgs loginArgs) { Debug.WriteLine("User Logged In: " + loginArgs.ToString()); this.userIdTextBox.Clear(); this.userIdTextBox.Text = loginArgs.userId; this.ActivateControls(true); }
/// <summary> /// Login event handler /// </summary> /// <param name="loginDialog"></param> /// <param name="loginArgs"></param> public void UserLogin(object loginDialog, UserLoginEventArgs loginArgs) { this.loggedInUser.Clear(); StringBuilder sb = new StringBuilder("User is logged in.").AppendLine().AppendLine(); sb.Append("User id: ").AppendLine(loginArgs.userId).AppendLine(); DateTime expiresAt = DateTime.Now; expiresAt.AddSeconds(loginArgs.expiersIn); sb.Append("Session expires in ").Append(loginArgs.expiersIn).AppendLine(" seconds."); this.loggedInUser.Text = sb.ToString(); this.EnableControls(); }
private void OnUserLogin(object loginDialog, UserLoginEventArgs loginArgs) { Debug.WriteLine("User Logged In: " + loginArgs); userId = loginArgs.userId; authToken = loginArgs.authToken; expiresAt = loginArgs.expiersIn; // todo: calc expiration time isAuthorized = true; userIdTextBox.Clear(); userIdTextBox.Text = "Authorized " + loginArgs.userId; ActivateControls(); }
private void UserLogin(object loginDialog, UserLoginEventArgs loginArgs) { Debug.WriteLine("User Logged In: " + loginArgs.ToString()); this.userId = loginArgs.userId; this.authToken = loginArgs.authToken; this.expiresAt = loginArgs.expiersIn; // todo: calc expiration time this.userIdTextBox.Clear(); this.userIdTextBox.Text = "Authorized " + loginArgs.userId; this.ActivateControls(); }
private void webBrowserLogin_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { Debug.WriteLine("DocumentCompleted"); Size webSize = webBrowserLogin.Document.Window.Size; this.Size = webSize; String stringUrl = webBrowserLogin.Url.ToString(); Debug.WriteLine(stringUrl); // Good response example // https://oauth.vk.com/blank.html#access_token=20660ffedf0d1d48533bee9b0931b2f0649b90c4a6592810de9b4961e30866910fd2cf2c7fb0a67878e7b&expires_in=86400&user_id=2927314 if (stringUrl.StartsWith(Secret.redirect_url)) { String[] tokens = System.Text.RegularExpressions.Regex.Split(stringUrl, "[=&#]"); for(int i = 0; i < tokens.Length; ++i) { Debug.Write("Token = " + tokens[i]); switch (tokens[i]) { case "access_token": if (i < tokens.Length) { this.authToken = tokens[++i]; Debug.WriteLine(" Value = " + tokens[i]); } break; case "expires_in": if (i < tokens.Length) { this.expiresIn = Convert.ToInt64(tokens[++i]); Debug.WriteLine(" Value = " + tokens[i]); } break; case "user_id": if (i < tokens.Length) { this.userId = tokens[++i]; Debug.WriteLine(" Value = " + tokens[i]); } break; default: Debug.WriteLine(" No Value"); break; } } // notify listeners if (OnUserLogin != null) { UserLoginEventArgs args = new UserLoginEventArgs(this.authToken, this.userId, this.expiresIn); OnUserLogin(this, args); } this.Close(); // close the dialog } }