private async void Submit_Click(object sender, RoutedEventArgs e) { Localclient = new Client(); SettingHandler.SetIpPort(TbIpPort.Text); if (TextBoxEmail.Text.Length == 0) { Errormessage.Text = "Bitte Email-Addresse eingeben"; TextBoxEmail.Focus(); } else if (!Regex.IsMatch(TextBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { Errormessage.Text = "Bitte eine gültige EMail-Addresse eingeben"; TextBoxEmail.Select(0, TextBoxEmail.Text.Length); TextBoxEmail.Focus(); } else { var sc = ServerConnection.CurrentInstance ?? new ServerConnection(); Localclient.UserName = TextBoxUserName.Text; Localclient.EMail = TextBoxEmail.Text; Localclient.EncPassword = new Encryption(PasswordBox1.Password).EncryptStringToBytes(PasswordBox1.Password); if (await sc.TryReg(Localclient)) { Errormessage.Text = "Erfolgreich Registriert"; } //TODOLOW: Needs a Close for the Reg Connection } }
private void ButtonLogin_Click(object sender, RoutedEventArgs e) { if (TextBoxEmail.Text.Length == 0) { ErrorMessage.Text = "Enter an email."; TextBoxEmail.Focus(); } else if (!Regex.IsMatch(TextBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { ErrorMessage.Text = "Enter a valid email."; TextBoxEmail.Select(0, TextBoxEmail.Text.Length); TextBoxEmail.Focus(); } else { string email = TextBoxEmail.Text; string password = passwordBox1.Password; if (_loginController.AuthenticateUser(email, password) == true) { string welcomeMessage = _loginController.GetCurrentUser(); MessageBox.Show(welcomeMessage); Reset(); FrameMain.Navigate(new ShowItemsView()); } else { ErrorMessage.Text = "Sorry! Please enter existing emailid/password."; } } }
private void Submit_Click(object sender, RoutedEventArgs e) { if (TextBoxEmail.Text.Length == 0) { Errormessage.Text = "Enter an email."; TextBoxEmail.Focus(); } else if (!Regex.IsMatch(TextBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { Errormessage.Text = "Enter a valid email."; TextBoxEmail.Select(0, TextBoxEmail.Text.Length); TextBoxEmail.Focus(); } else { string firstname = TextBoxFirstName.Text; string lastname = TextBoxLastName.Text; string email = TextBoxEmail.Text; string password = PasswordBox1.Password; if (PasswordBox1.Password.Length == 0) { Errormessage.Text = "Enter password."; PasswordBox1.Focus(); } else if (PasswordBoxConfirm.Password.Length == 0) { Errormessage.Text = "Enter Confirm password."; PasswordBoxConfirm.Focus(); } else if (PasswordBox1.Password != PasswordBoxConfirm.Password) { Errormessage.Text = "Confirm password must be same as password."; PasswordBoxConfirm.Focus(); } else { Errormessage.Text = ""; User newUser = new User() { Pass = password, Email = email, FirstName = firstname, LastName = lastname, RegistrationDate = DateTime.Now }; if (SaveToDatabase(newUser)) { Errormessage.Text = "You have Registered successfully."; RedirectToLoginPage(newUser); Reset(); } } } }
private void ButtonSubmit_Click(object sender, RoutedEventArgs e) { if (TextBoxEmail.Text.Length == 0) { ErrorMessage.Text = "Enter an email."; TextBoxEmail.Focus(); } else if (!Regex.IsMatch(TextBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { ErrorMessage.Text = "Enter a valid email."; TextBoxEmail.Select(0, TextBoxEmail.Text.Length); TextBoxEmail.Focus(); } else { string firstName = TextBoxFirstName.Text; string lastName = TextBoxLastName.Text; string email = TextBoxEmail.Text; string password = PasswordBox1.Password; if (PasswordBox1.Password.Length == 0) { ErrorMessage.Text = "Enter password."; PasswordBox1.Focus(); } else if (PasswordBoxConfirm.Password.Length == 0) { ErrorMessage.Text = "Enter Confirm password."; PasswordBoxConfirm.Focus(); } else if (PasswordBox1.Password != PasswordBoxConfirm.Password) { ErrorMessage.Text = "Confirm password must be same as password."; PasswordBoxConfirm.Focus(); } else { ErrorMessage.Text = ""; _registerController.CreateNewUser(firstName, lastName, email, password); ErrorMessage.Text = "You have Registered successfully."; Reset(); FrameMain.Navigate(new ShowItemsView()); } } }