private void btnChange_Click(object sender, RoutedEventArgs e) { if (txtPass.Password.Equals("")) { MessageBox.Show("Email or Pass is must be filled"); } else if (txtRePass.Password.ToString() != txtPass.Password.ToString()) { MessageBox.Show("Your Password not same"); } else { var validate = context.Suppliers.Where(x => x.Email.Contains(getEmail.Text)).SingleOrDefault(); var bcrypt = Bcrypt.HashPassword(txtPass.Password); var getId = context.Suppliers.Find(Convert.ToInt32(validate.Id)); getId.Name = validate.Name; getId.Email = validate.Email; getId.Pass = bcrypt; getId.Guid = ""; context.SaveChanges(); MessageBox.Show("Change Password Successfully"); LoginWindow login = new LoginWindow(); login.Show(); this.Close(); } }
private void Login_Click(object sender, RoutedEventArgs e) { LoginWindow login = new LoginWindow(); login.Show(); this.Close(); }
private void ButtonPopUpLogo_Click(object sender, RoutedEventArgs e) { //Application.Current.Shutdown(); LoginWindow login = new LoginWindow(); login.Show(); this.Close(); }
private void Submit_Click(object sender, RoutedEventArgs e) { string generate = Guid.NewGuid().ToString().Substring(0, 8); string passTemp = BCrypt.Net.BCrypt.HashPassword(generate); try { Login login = _context.Logins.Where(l => l.Email == emailBox.Text).First(); login.Password = passTemp; login.IsForgot = true; _context.SaveChanges(); mail.To.Add(new MailAddress(emailBox.Text)); mail.Body = emailBody(emailBox.Text, generate); sendEmail.Send(mail); _context.SaveChanges(); MessageBox.Show("Email has been sent"); loginWin.Show(); Close(); } catch (Exception) { if (!_emailValid.IsMatch(emailBox.Text)) { warning.Visibility = Visibility.Visible; emailBox.Text = ""; } else if (!EmailExist(emailBox.Text)) { warning.Text = "email does not exist"; warning.Visibility = Visibility.Visible; emailBox.Text = ""; } else { MessageBox.Show("Error sending email."); } } }
private void btnSignUp_Click(object sender, RoutedEventArgs e) { var validate = context.Suppliers.Where(x => x.Email.Contains(txtEmail.Text)).SingleOrDefault(); var regex = @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z"; bool isValid = Regex.IsMatch(txtEmail.Text, regex, RegexOptions.IgnoreCase); if (string.IsNullOrWhiteSpace(txtEmail.Text) || txtPass.Password.Equals("") || txtNama.Text.Equals("")) { MessageBox.Show("Email or Pass or is must be filled"); } else if (!isValid) { MessageBox.Show("Invalid Email Address"); } else if (txtRePass.Password.ToString() != txtPass.Password.ToString()) { MessageBox.Show("Your Password not same"); } else { if (validate != null) { MessageBox.Show("Email Already Exist"); } else { var bcrypt = Bcrypt.HashPassword(txtPass.Password); var input = new Supplier(txtNama.Text, txtEmail.Text, bcrypt.ToString()); context.Suppliers.Add(input); context.SaveChanges(); MessageBox.Show("Register Successfully"); login.Show(); this.Close(); } } }
private void btnForgot_Click(object sender, RoutedEventArgs e) { client.Port = 587; client.Host = "smtp.gmail.com"; client.EnableSsl = true; client.Timeout = 10000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(mail, pass); var guid = Guid.NewGuid(); var validate = context.Suppliers.Where(x => x.Email.Contains(txtEmail.Text)).SingleOrDefault(); var fill = "Hi " + validate.Name + "\n\n" + "Try this Password to get into reset password: \n" + guid + "\n\nThank You"; MailMessage mm = new MailMessage("*****@*****.**", txtEmail.Text, "Forgot Email", fill); mm.BodyEncoding = UTF8Encoding.UTF8; mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(mm); var bcrypt = Bcrypt.HashPassword(guid.ToString()); var getId = context.Suppliers.Find(Convert.ToInt32(validate.Id)); getId.Name = validate.Name; getId.Email = validate.Email; getId.Pass = ""; getId.Guid = Bcrypt.HashPassword(bcrypt); context.SaveChanges(); MessageBox.Show("Check Your Email"); LoginWindow login = new LoginWindow(); login.Show(); this.Close(); }