private async void RegisterButton_Click(object sender, RoutedEventArgs e) { string username = this.usernameTxtBox.Text; string password = this.passwordTxtBox.Password; Config conf = Config.Instance(); if (username.Equals("")) { UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing username! Username field cannot be empty."); return; } if (password.Equals("")) { UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing password! Password field cannot be empty."); return; } BackupServiceClient server = new BackupServiceClient(); string salt; try { salt = server.registerStep1(username); } catch { UsefullMethods.setLabelAlert("danger", this.errorBox, "No internet connection! Check it and retry"); return; } if (salt == null) { UsefullMethods.setLabelAlert("danger", this.errorBox, "Username already choosen! Try another!"); return; } if (server.registerStep2(username, AuthenticationPrimitives.hashPassword(password, salt), salt)) { conf.targetPath.set(null); conf.userName.set(username); UsefullMethods.setLabelAlert("success", this.errorBox, "Registration succeed. You can log in now."); await Task.Delay(500); this.Hide(); this.parent.Activate(); this.parent.Show(); } else { UsefullMethods.setLabelAlert("danger", this.errorBox, "Registration procedure failed!"); } }
private void RegisterButton_Click(object sender, RoutedEventArgs e) { string username = this.usernameTxtBox.Text; string password = this.passwordTxtBox.Password; if (username.Equals("")) { UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing username! Username field cannot be empty."); return; } if (password.Equals("")) { UsefullMethods.setLabelAlert("danger", this.errorBox, "Missing password! Password field cannot be empty."); return; } BackupServiceClient server = new BackupServiceClient(); string salt; try { salt = server.registerStep1(username); } catch { UsefullMethods.setLabelAlert("danger", this.errorBox, "No internet connection!Check it and retry"); return; } if (salt == null) { UsefullMethods.setLabelAlert("danger", this.errorBox, "Username already choosen! Try another!"); return; } if (server.registerStep2(username, AuthenticationPrimitives.hashPassword(password, salt), salt)) { UsefullMethods.setLabelAlert("danger", this.errorBox, "Registration succeed. You can log in now."); Thread.Sleep(500); this.Hide(); this.parent.Activate(); this.parent.Show(); } else { UsefullMethods.setLabelAlert("danger", this.errorBox, "Registration procedure failed!"); } }
private void RegisterButton_Click(object sender, RoutedEventArgs e) { string username = this.usernameTxtBox.Text; string password = this.passwordTxtBox.Password; if (username.Equals("")) { MessageBox.Show(this, "Username cannot be empty!", "Missing username", MessageBoxButton.OK); return; } if (password.Equals("")) { MessageBox.Show(this, "Password cannot be empty!", "Missing password", MessageBoxButton.OK); return; } BackupServiceClient server = new BackupServiceClient(); string salt = server.registerStep1(username); if (salt == null) { MessageBox.Show(this, "Username already choosen! Try another!", "Registration problem", MessageBoxButton.OK); return; } if (server.registerStep2(username, AuthenticationPrimitives.hashPassword(password, salt), salt)) { MessageBox.Show(this, "Registration succeed. You can log in now.", "Registration succeed!", MessageBoxButton.OK); this.Hide(); this.parent.Activate(); this.parent.Show(); } else { MessageBox.Show(this, "Registration procedure failed!", "Error", MessageBoxButton.OK); } }