protected bool PasswordMatch(CustomerHistoryPassword customerPassword, ChangePasswordRequest request) { string newPwd = request.PasswordFormat switch { PasswordFormat.Clear => request.NewPassword, PasswordFormat.Encrypted => _encryptionService.EncryptText(request.NewPassword, customerPassword.PasswordSalt), PasswordFormat.Hashed => _encryptionService.CreatePasswordHash(request.NewPassword, customerPassword.PasswordSalt, _customerSettings.HashedPasswordFormat), _ => throw new Exception("PasswordFormat not supported"), }; return(customerPassword.Password.Equals(newPwd)); }
protected bool PasswordMatch(CustomerHistoryPassword customerPassword, ChangePasswordRequest request) { string newPwd = ""; switch (request.NewPasswordFormat) { case PasswordFormat.Encrypted: newPwd = _encryptionService.EncryptText(request.NewPassword); break; case PasswordFormat.Hashed: newPwd = _encryptionService.CreatePasswordHash(request.NewPassword, customerPassword.PasswordSalt, _customerSettings.HashedPasswordFormat); break; default: newPwd = request.NewPassword; break; } return(customerPassword.Password.Equals(newPwd)); }
/// <summary> /// Insert a customer history password /// </summary> /// <param name="customer">Customer</param> public virtual async Task InsertCustomerPassword(Customer customer) { if (customer == null) { throw new ArgumentNullException(nameof(customer)); } var chp = new CustomerHistoryPassword { Password = customer.Password, PasswordFormatId = customer.PasswordFormatId, PasswordSalt = customer.PasswordSalt, CustomerId = customer.Id, CreatedOnUtc = DateTime.UtcNow }; await _customerHistoryPasswordProductRepository.InsertAsync(chp); //event notification await _mediator.EntityInserted(chp); }