<commit_before># frozen_string_literal: true

module User::ApiAuthenticationHelper
  extend ActiveSupport::Concern

  private

  def current_user
    @current_user ||= find_current_user
  end

  def user_signed_in?
    current_user.present?
  end

  def admin_authorized?
    find_current_admin.present? && current_admin.sites.include?(current_site)
  end

  def authenticate_user!
    raise_unauthorized unless user_signed_in?
  end

  # The host is not checked if request is internal or the site is not password
  # protected
  def check_host
    return if internal_site_request? || !site_protected? || api_token_with_host.present?<commit_msg>Fixes current admin check<commit_after># frozen_string_literal: true

module User::ApiAuthenticationHelper
  extend ActiveSupport::Concern

  private

  def current_user
    @current_user ||= find_current_user
  end

  def user_signed_in?
    current_user.present?
  end

  def admin_authorized?
    (@current_admin = find_current_admin).present? &&
      @current_admin.sites.include?(current_site)
  end

  def authenticate_user!
    raise_unauthorized unless user_signed_in?
  end

  # The host is not checked if request is internal or the site is not password
  # protected
  def check_host
    return if internal_site_request? || !site_protected? || api_token_with_host.present?
{'fraction_non_alphanumeric': 0.0625, 'fraction_numerical': 0.0, 'mean_word_length': 4.5375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6717734', 'n_tokens_mistral': 409, 'n_tokens_neox': 392, 'n_words': 105}