<commit_before>class CasController < ApplicationController
  skip_before_filter :verify_authenticity_token, :only => :verify
  before_filter RubyCAS::Filter, :only => :verify

  def auth
    if params[:redirect]
      session[:post_cas_redirect] = params[:redirect]
    end

    if request.referer =~ /ugent.be/
      session[:unipept] = true
    end

    redirect_to cas_verify_path
  end

  def verify
    # After redirection the session will contain information like this
    # {
    #    "cas_sent_to_gateway"=>false,
    #    "cas_validation_retry_count"=>0,
    #    "previous_redirect_to_cas"=>2011-07-30 11:08:02 +0200,
    #    "cas_user"=>"pdbaets",
    #    "cas_extra_attributes"=>{
    #      "uid"=>"pdbaets", "mail"=>"<EMAIL>", "givenname"=>"Pieter",
    #      "surname"=>"<NAME>", "objectClass"=>"ugentDictUser",
    #      "lastenrolled"=>"2010 - 2011", "ugentStudentID"=>"00801234"
    #    },
    #    "casfilteruser"=>"pdbaets", "cas_last_valid_ticket"=>nil
    # }

    # Don't save the ticket, it contains a singleton somewhere that can't be marshalled
    session[:cas_last_valid_ticket] = nil

    if session[:post_cas_redirect]
      redirect_to session[:post_cas_redirect]
    else
      redirect_to root_url
    end
  end

  def logout
    RubyCAS::Filter.logout(self, root_url)
  end
end<commit_msg>add check for valid account<commit_after>class CasController < ApplicationController
  skip_before_filter :verify_authenticity_token, :only => :verify
  before_filter RubyCAS::Filter, :only => :verify

  def auth
    # if the redirect parameter is set, redirect to this page after auth
    if params[:redirect]
      session[:post_cas_redirect] = params[:redirect]
    end

    redirect_to cas_verify_path
  end

  def verify
    # After redirection the session will contain information like this
    # {
    #    "cas_sent_to_gateway"=>false,
    #    "cas_validation_retry_count"=>0,
    #    "previous_redirect_to_cas"=>2011-07-30 11:08:02 +0200,
    #    "cas_user"=>"pdbaets",
    #    "cas_extra_attributes"=>{
    #      "uid"=>"pdbaets", "mail"=>"<EMAIL>", "givenname"=>"Pieter",
    #      "surname"=>"<NAME>", "objectClass"=>"ugentDictUser",
    #      "lastenrolled"=>"2010 - 2011", "ugentStudentID"=>"00801234"
    #    },
    #    "casfilteruser"=>"pdbaets", "cas_last_valid_ticket"=>nil
    # }

    # Don't save the ticket, it contains a singleton somewhere that can't be marshalled
    session[:cas_last_valid_ticket] = nil
    
    # check if the logged in user is an administrator.
    if session[cas_user] != "bmesuere"
      flash[:error] = "Sorry, you are not an administrator"
      session[cas_user] = nil
    end
    
    # if the redirect parameter is set, redirect to this page after auth
    if session[:post_cas_redirect]
      redirect_to session[:post_cas_redirect]
    else
      redirect_to root_url
    end
  end

  def logout
    RubyCAS::Filter.logout(self, root_url)
  end
end
{'fraction_non_alphanumeric': 0.11972789115646258, 'fraction_numerical': 0.023809523809523808, 'mean_word_length': 3.4292168674698793, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 39, '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': '1189941', 'n_tokens_mistral': 1055, 'n_tokens_neox': 971, 'n_words': 213}