<commit_before># Users configuration
module DeboxServer
  module Users
    include DeboxServer::Utils
    include DeboxServer::Config

    # Return a valid user with the given credentials or false if not found
    def login_user(email, clean_password)
      user_data = find_user email
      return false unless user_data
      password = user_data.password
      return false unless password == <PASSWORD>(clean_password)
      return user_data
    end

    def login_api_key(email, api_key)
      user_data = find_user(email)
      return false unless user_data && user_data.api_key == api_key
      return user_data
    end

    def find_user(email)
      user = redis.hget('users', email)
      if user
        OpenStruct.new JSON.parse(user)
      else
        false
      end
    end

    def add_user(email, password)
      user = { email: email, password: <PASSWORD>(password), api_key: generate_uuid }
      redis.hsetnx 'users', email, user.to_json
      return OpenStruct.new user
    end

    # Return the content of the users config file
    def users_config
      redis.hgetall('users') || {}
    end

  end
end
<commit_msg>Force save redis after create user<commit_after># Users configuration
module DeboxServer
  module Users
    include DeboxServer::Utils
    include DeboxServer::Config

    # Return a valid user with the given credentials or false if not found
    def login_user(email, clean_password)
      user_data = find_user email
      return false unless user_data
      password = user_data.password
      return false unless password == <PASSWORD>(<PASSWORD>)
      return user_data
    end

    def login_api_key(email, api_key)
      user_data = find_user(email)
      return false unless user_data && user_data.api_key == api_key
      return user_data
    end

    def find_user(email)
      user = redis.hget('users', email)
      if user
        OpenStruct.new JSON.parse(user)
      else
        false
      end
    end

    def add_user(email, password)
      user = { email: email, password: <PASSWORD>(password), api_key: generate_uuid }
      redis.hsetnx 'users', email, user.to_json
      redis.save
      return OpenStruct.new user
    end

    # Return the content of the users config file
    def users_config
      redis.hgetall('users') || {}
    end

  end
end

{'fraction_non_alphanumeric': 0.06796536796536796, 'fraction_numerical': 0.0, 'mean_word_length': 2.715434083601286, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3187809', 'n_tokens_mistral': 679, 'n_tokens_neox': 666, 'n_words': 212}