<commit_before>class ApplicationController < ActionController::Base

# before_filter :authenticate_user!

  include Pundit
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized

  helper_method :nat_instance

  private

  def nat_instance(nat_instance = nil)
    @nat_instance ||= nat_instance
  end

  def user_not_authorized
    flash[:alert] = "Access denied."
    redirect_to (request.referrer || root_path)
  end

  def authenticate_admin
    if user_signed_in?<commit_msg>Write nicer unauthorized flash message<commit_after>class ApplicationController < ActionController::Base

# before_filter :authenticate_user!

  include Pundit
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized

  helper_method :nat_instance

  private

  def nat_instance(nat_instance = nil)
    @nat_instance ||= nat_instance
  end

  def user_not_authorized
    flash[:alert] = "Sorry, you don't have the permissions to do that."
    redirect_to (request.referrer || root_path)
  end

  def authenticate_admin
    if user_signed_in?
{'fraction_non_alphanumeric': 0.06557377049180328, 'fraction_numerical': 0.0, 'mean_word_length': 4.739316239316239, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7307938', 'n_tokens_mistral': 419, 'n_tokens_neox': 397, 'n_words': 114}