<commit_before>module Coursewareable
  # Courseware application controller
  class ApplicationController < ::ApplicationController
    # Ask users to authenticate
    before_filter :require_login

    # Handle errors
    rescue_from CanCan::AccessDenied, :with => :unauthorized
    rescue_from ActiveRecord::RecordNotFound, :with => :not_found

    private

    # Sorcery method overwritten to customize error message
    def not_authenticated
      redirect_to(login_url, :alert => _('Please authenticate first.'))
    end

    # Unauthorized error handler
    def unauthorized
      redirect_to(login_url, :alert => _('Access to this page is restricted.'))
    end

    # Not found handler<commit_msg>Redirect to relevant subdomain if request came from there.<commit_after>module Coursewareable
  # Courseware application controller
  class ApplicationController < ::ApplicationController
    # Ask users to authenticate
    before_filter :require_login

    # Handle errors
    rescue_from CanCan::AccessDenied, :with => :unauthorized
    rescue_from ActiveRecord::RecordNotFound, :with => :not_found

    private

    # Sorcery method overwritten to customize error message
    def not_authenticated
      args = {:subdomain => request.subdomain} unless request.subdomain.blank?
      redirect_to(login_url(args), :alert => _('Please authenticate first.'))
    end

    # Unauthorized error handler
    def unauthorized
      args = {:subdomain => request.subdomain} unless request.subdomain.blank?
      redirect_to(
        login_url(args), :alert => _('Access to this page is restricted.') )
    end

    # Not found handler
{'fraction_non_alphanumeric': 0.07541385652973635, 'fraction_numerical': 0.0, 'mean_word_length': 3.857142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '4150210', 'n_tokens_mistral': 431, 'n_tokens_neox': 412, 'n_words': 132}