private void Save_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(usenameText.Text)) { MessageBox.Show("Please type in your ussername"); } else if (String.IsNullOrEmpty(passwordText.Text)) { MessageBox.Show("Please type in your password"); } else { GetInfo getInfo = new GetInfo(); int check = getInfo.checkUserCredentials(usenameText.Text, passwordText.Text); TestApiKey testApiKey = new TestApiKey(); string testRezults = testApiKey.testApiKey(UserGetSet.apiKey); YourTube yourTube = new YourTube(); if (testRezults == "Bad") { MessageBox.Show("Your Api Key has expired please change it"); this.Hide(); yourTube.Show(); } else if (check == 1) { this.Hide(); yourTube.Show(); } else { MessageBox.Show("Error your credentials are bad"); } } }
private void Save_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(usernameText.Text)) { MessageBox.Show("Please type in your username"); } else if (String.IsNullOrEmpty(passwrodText.Text)) { MessageBox.Show("Please type in your password"); } else if (String.IsNullOrEmpty(repeatPasswordText.Text)) { MessageBox.Show("Please type in your repeat password"); } else if (String.IsNullOrEmpty(apiKeyText.Text)) { MessageBox.Show("Please type in your Api key"); } else if (passwrodText.Text != repeatPasswordText.Text) { MessageBox.Show("Your passwords don't mach"); } //GetUsersUsername getUsersUsername = new GetUsersUsername(); GetInfo getInfo = new GetInfo(); List <string> usernames = getInfo.getUserUsername(); bool isRegistered = false; foreach (string data in usernames) { if (data == usernameText.Text) { MessageBox.Show("Change ussername"); isRegistered = true; } } if (isRegistered == false) { TestApiKey testApiKey = new TestApiKey(); string testRezult = testApiKey.testApiKey(apiKeyText.Text); if (testRezult == "Bad") { MessageBox.Show("Your Api key is invalid"); } else { AddInfo addInfo = new AddInfo(); addInfo.addNewUser(usernameText.Text, passwrodText.Text, apiKeyText.Text); MessageBox.Show("Your have registered successfully"); this.Hide(); Login login = new Login(); login.Show(); } } }
private void Save_Click(object sender, EventArgs e) { TestApiKey testApiKey = new TestApiKey(); string testResult = testApiKey.testApiKey(textBoxKey.Text); if (testResult == "Bad") { MessageBox.Show("This Api key is invalid"); } else { SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source=YourTubeDB.db; Version = 3; New = True; Compress = True; "); sqlite_conn.Open(); SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand(); sqlite_cmd.CommandText = "UPDATE User SET ApiKey = '" + textBoxKey.Text + "' WHERE Username = '******'"; sqlite_cmd.ExecuteNonQuery(); UserGetSet.apiKey = textBoxKey.Text; MessageBox.Show("Your API has been saved successfully"); this.Hide(); YourTube yourTube = new YourTube(); yourTube.Show(); } }
public void ApiKeyTest_GoodKey() { TestApiKey testApiKey = new TestApiKey(); Assert.AreEqual("Bad", testApiKey.testApiKey("6432adasd84")); }
public void ApiKeyTest_BadApiKey() { TestApiKey testApiKey = new TestApiKey(); Assert.AreEqual("good", testApiKey.testApiKey("AIzaSyCBYx5nDeHanit6rpvzhZLSDy52diu7ecI")); }