<commit_before>class ApplicationController < ActionController::Base
  #protect_from_forgery
  layout 'application'
  session :on
  
  # use the custom responder from RestfulJSONP to handle
  # JSONP requests
  self.responder = RestfulJSONP::JSONPResponder
  
  protected
  def must_be_admin
    unless authenticated_as && User.find(authenticated_as).is_admin?
      redirect_to login_path(:destination => request.url), 
        :notice => "You must log in as an admin to access the requested area." #, :status => :unauthorized
    end
  end
  
  def authenticated_as
    session[:auth_session_id] && authenticated_session.account.for
  end
  helper_method :authenticated_as
  
  def authenticated_session
    session[:auth_session_id] && Session.find(session[:auth_session_id])
  end
  helper_method :authenticated_session
  
  def authenticate(sess)
    if sess.account.for.kind_of?(User)
      session[:auth_session_id] = sess.id
    else
      raise "Only users can authenticate for rollcall administration. Current account is: #{sess.account.inspect}"
    end
  end
end<commit_msg>account.for.inspect instead of account.inspect in authentication error message<commit_after>class ApplicationController < ActionController::Base
  #protect_from_forgery
  layout 'application'
  session :on
  
  # use the custom responder from RestfulJSONP to handle
  # JSONP requests
  self.responder = RestfulJSONP::JSONPResponder
  
  protected
  def must_be_admin
    unless authenticated_as && User.find(authenticated_as).is_admin?
      redirect_to login_path(:destination => request.url), 
        :notice => "You must log in as an admin to access the requested area." #, :status => :unauthorized
    end
  end
  
  def authenticated_as
    session[:auth_session_id] && authenticated_session.account.for
  end
  helper_method :authenticated_as
  
  def authenticated_session
    session[:auth_session_id] && Session.find(session[:auth_session_id])
  end
  helper_method :authenticated_session
  
  def authenticate(sess)
    if sess.account.for.kind_of?(User)
      session[:auth_session_id] = sess.id
    else
      raise "Only users can authenticate for rollcall administration. Current account is: #{sess.account.for.inspect}"
    end
  end
end
{'fraction_non_alphanumeric': 0.07682000893255918, 'fraction_numerical': 0.0, 'mean_word_length': 4.137614678899083, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '399822', 'n_tokens_mistral': 688, 'n_tokens_neox': 661, 'n_words': 170}