<commit_before># open API to create articles
class Api::ArticlesController < ApplicationController
  skip_before_action :verify_authenticity_token
  before_action :log_request, :authenticate

  TOKEN = '<PASSWORD>'

  def create
    article = Article.new(article_params).extend(MetaTagsParser)
    article.parse
    if article.valid?
      article.save
      render plain: 'article successfuly created. Congratulations!', status: :ok
    else
      render plain: creating_error_message(article.errors), status: :bad_request
    end
  end

  private
  def authenticate
    authenticate_or_request_with_http_token do |token|
      # Compare the tokens in a time-constant manner, to mitigate
      # timing attacks.
      ActiveSupport::SecurityUtils.secure_compare(<commit_msg>use env variable as auth token<commit_after># open API to create articles
class Api::ArticlesController < ApplicationController
  skip_before_action :verify_authenticity_token
  before_action :log_request, :authenticate

  TOKEN = ENV['AUTH_TOKEN']

  def create
    article = Article.new(article_params).extend(MetaTagsParser)
    article.parse
    if article.valid?
      article.save
      render plain: 'article successfuly created. Congratulations!', status: :ok
    else
      render plain: creating_error_message(article.errors), status: :bad_request
    end
  end

  private
  def authenticate
    authenticate_or_request_with_http_token do |token|
      # Compare the tokens in a time-constant manner, to mitigate
      # timing attacks.
      ActiveSupport::SecurityUtils.secure_compare(
{'fraction_non_alphanumeric': 0.06743002544529263, 'fraction_numerical': 0.0, 'mean_word_length': 4.1743421052631575, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, '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': '120933', 'n_tokens_mistral': 447, 'n_tokens_neox': 426, 'n_words': 120}