<commit_before>class InvitesController < ApplicationController
  unloadable
  
  skip_before_filter :login_required
  
  def index
    # Redirect if we don't need an invite as we don't need the user to see this page
    redirect_to "/" and return if doesnt_need_an_invite
  end
  
  def show
    # Redirect if we don't need an invite as we don't need the user to see this page
    redirect_to "/" and return if doesnt_need_an_invite
    # Otherwise, we find the invite, and set it in the session if it was valid
    @invite = find_invite(params[:id])
    session[:invite] = @invite.slug unless @invite.nil?
  end
  
  def create
    # We'll redirect back to the main page if no code, or an empty code was supplied
    if params["invite"].blank? || params["invite"]["code"].blank?
      redirect_to invites_path
    else
      # Otherwise we redirect to the show action with the specified code
      redirect_to invite_path(params["invite"]["code"])
    end
  end
end<commit_msg>Creating a before_filter to check if invites are required. More DRY this way<commit_after>class InvitesController < ApplicationController
  unloadable
  
  skip_before_filter :login_required
  before_filter :check_if_invite_required, :only => %w(index show)
  
  def index
    render
  end
  
  def show
    # Otherwise, we find the invite, and set it in the session if it was valid
    @invite = find_invite(params[:id])
    session[:invite] = @invite.slug unless @invite.nil?
  end
  
  def create
    # We'll redirect back to the main page if no code, or an empty code was supplied
    if params["invite"].blank? || params["invite"]["code"].blank?
      redirect_to invites_path
    else
      # Otherwise we redirect to the show action with the specified code
      redirect_to invite_path(params["invite"]["code"])
    end
  end
  
  private
    def check_if_invite_required
      # Redirect if we don't need an invite as we don't need the user to see this page
      redirect_to "/" and return if doesnt_need_an_invite
    end
end
{'fraction_non_alphanumeric': 0.06901688182720954, 'fraction_numerical': 0.0, 'mean_word_length': 3.370932754880694, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1542416', 'n_tokens_mistral': 605, 'n_tokens_neox': 599, 'n_words': 233}