public static Verify ( string text, string hash ) : bool | ||
text | string | The text to verify. |
hash | string | The previously-hashed password. |
Résultat | bool |
private void btnLogin_Click(object sender, RoutedEventArgs e) { var validate = context.Suppliers.Where(x => x.Email.Contains(txtEmail.Text)).SingleOrDefault(); if (string.IsNullOrWhiteSpace(txtEmail.Text) || txtPass.Password.Equals("")) { MessageBox.Show("Email or Pass is must be filled"); } //else if (!txtEmail.Text.All(char.IsLetterOrDigit)) //{ // MessageBox.Show("*Name Must Contain Only number and text !"); //} //else if (!IsValidEmailRegex(txtEmail.Text)) else if (!Validate(txtEmail.Text)) { MessageBox.Show("Invalid Email Address"); } else if (validate == null) { MessageBox.Show("Email not available, you must be register"); } else { //if (txtEmail.Text != validate.Email && txtPass.Text != validate.Pass) if (txtEmail.Text == validate.Email && Bcrypt.Verify(txtPass.Password, validate.Pass) == true) { if (validate.Guid.Equals("")) { if (rememberMe.IsChecked == true) { Properties.Settings.Default.Mail = txtEmail.Text; Properties.Settings.Default.Password = txtPass.Password; Properties.Settings.Default.Save(); } MainWindow main = new MainWindow(); main.Show(); } else { ChangePassWindow changePass = new ChangePassWindow(); changePass.getEmail.Text = txtEmail.Text; changePass.Show(); } this.Close(); } else { MessageBox.Show("Email or Pass is wrong"); } } }
public async Task <User> AuthenticateAsync(string username, string password) { var user = await _dataContext.Users.SingleOrDefaultAsync(u => u.Username == username); if (user == null || !BC.Verify(password, user.Password)) { throw new LogicException("Неправильный логин или пароль"); } else { GenerateToken(user); return(user.WithoutPassword()); } }