old_contents: __author__ = 'matt'
  
  from blockbuster import bb_dbconnector_factory
  
  
  def credentials_are_valid(username, password):
      db = bb_dbconnector_factory.DBConnectorInterfaceFactory().create()
      print(username)
      result = db.api_credentials_are_valid(username, password)
      print (result)
      return result
  
new_contents: __author__ = 'matt'
  
  from werkzeug.security import generate_password_hash, check_password_hash
  
  from blockbuster import bb_auditlogger
  from blockbuster import bb_dbconnector_factory
  
  auditor = bb_auditlogger.BBAuditLoggerFactory().create()
  
  
  def credentials_are_valid(username, password):
      db = bb_dbconnector_factory.DBConnectorInterfaceFactory().create()
      credentials = db.get_api_credentials(username)
  
      # Check whether the provided username exists in the system (this is purely for logging purposes)
      username_exists = True if credentials else False
      auditor.logAudit('app',
                       'USER_CHECK',
                       str.format("Username '{0}' exists: {1}", username, username_exists))
  
      # Given that the user is valid, check the password
      password_valid = False
      if credentials:
          password_valid = check_password_hash(credentials['password'], password)
          auditor.logAudit('app',
                           'PWD_CHECK',
                           str.format("Password valid for user '{0}': {1}", username, password_valid))
  
      return password_valid
  
subject: Move logic for validating user against records in database into this bb_security file. Implement use of password_hashes instead of plain text.