private void registerButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (passwordBox.Text != textBox2.Text)
         {
             MessageBox.Show("Passwords do not match!", "Password", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (ClientApp.GetServer().RegisterUser(nicknameBox.Text, textBox2.Text, passwordBox.Text))
         {
             Console.WriteLine(@"Registration worked");
             ActiveUser newUser = ClientApp.GetServer().LoginUser(nicknameBox.Text, passwordBox.Text, ClientApp.GetInstance().Address);
             if (newUser != null)
             {
                 ClientApp.SetLoggedUser(newUser);
                 Console.WriteLine(@"Login worked");
                 this.Hide();
                 ClientApp.SetMainWindow(new MainWindow(newUser));
                 ClientApp.GetMainWindow().ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("8 characters minimum;" + Environment.NewLine + "Can not have white spaces, <, >, \' or \"", "Password Rules", MessageBoxButtons.OK);
         }
     }
     catch (Exception ex)
     {
         ClientApp.LaunchServerError(ex.Message);
     }
 }
Exemple #2
0
 private void loginButton_Click(object sender, EventArgs e)
 {
     try
     {
         ActiveUser newUser = ClientApp.GetServer().LoginUser(nicknameBox.Text, passwordBox.Text, ClientApp.GetInstance().Address);
         if (newUser != null)
         {
             ClientApp.SetLoggedUser(newUser);
             Console.WriteLine(@"Login worked");
             this.Hide();
             ClientApp.SetMainWindow(new MainWindow(newUser));
             ClientApp.GetMainWindow().ShowDialog();
         }
         else
         {
             MessageBox.Show("Login Failed: Be sure that you were registred with those credentials",
                             "Login Failed",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
             nicknameBox.Text = "";
             passwordBox.Text = "";
         }
     }
     catch (Exception ex)
     {
         ClientApp.LaunchServerError(ex.Message);
     }
 }