<commit_before>require 'casclient/frameworks/rails/filter'
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  helper_method :current_user # make current_user a helper method, which can be called from views
  
  protect_from_forgery # See ActionController::RequestForgeryProtection for details

  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password

  # Ensures logging in with CAS before seeing ANY view at all
  before_filter CASClient::Frameworks::Rails::Filter

  # Defines the current_user method for use by the CanCan gem
  def current_user
    # TO BE IMPLEMENTED!!!
    # CAS LDAP ID (session[:cas_user]) is the most consistent way of identification
    # User.find_by_ldap_id(session[:cas_user])
    # for now simply set current_user to be session[:cas_user]
    session[:cas_user]
  end
  
  def logout
    #st = session[:cas_last_valid_ticket]
    #delete_service_session_lookup(st) if st
    #reset_session
    #protocol = request.ssl? ? 'https://' : 'http://'
    #app_url = "localhost:3000/"
    #logout_url = "https://auth-test.berkeley.edu/cas/logout"
    
    #redirect_to("#{logout_url}?url=#{protocol}#{app_url}")    
    
    # CASClient::Frameworks::Rails::Filter.logout(self) will call the above lines. What's the reason for writing them again?
    CASClient::Frameworks::Rails::Filter.logout(self)<commit_msg>refactored, and merged cas_example code into main application<commit_after>require 'casclient/frameworks/rails/filter'
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  helper_method :current_user # make current_user a helper method, which can be called from views
  before_filter CASClient::Frameworks::Rails::Filter  # Ensures logging in with CAS before seeing ANY view at all
  protect_from_forgery # See ActionController::RequestForgeryProtection for details

  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password

  # Defines the current_user method for use by the CanCan gem
  def current_user
    # TO BE IMPLEMENTED!!!
    # CAS LDAP ID (session[:cas_user]) is the most consistent way of identification
    # User.find_by_ldap_id(session[:cas_user])
    # for now simply set current_user to be session[:cas_user]
    session[:cas_user]
  end
  
  def logout
    CASClient::Frameworks::Rails::Filter.logout(self)
{'fraction_non_alphanumeric': 0.07737440410707737, 'fraction_numerical': 0.0014668133480014668, 'mean_word_length': 4.671517671517671, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4428238', 'n_tokens_mistral': 790, 'n_tokens_neox': 762, 'n_words': 264}