<commit_before># ApplicationController
class ApplicationController < ActionController::Base
  before_action :store_user_location!, if: :storable_location?
  # The callback which stores the current location must be added before you
  # authenticate the user as `authenticate_user!` (or whatever your resource is)
  # will halt the filter chain and redirect before the location can be stored.
  before_action :authenticate_user!
  before_action :set_locale

  # show error message if authorization with cancancan fails
  rescue_from CanCan::AccessDenied do |exception|
    redirect_to main_app.root_url, alert: exception.message
  end

  # determine where to send the user after login
  def after_sign_in_path_for(resource_or_scope)
    # checks if user consented to DSGVO and has ever edited his/her profile
    # if profile was never edited, redirect to profil editing
    stored_location_for(resource_or_scope) || super
  end

  private

  # It's important that the location is NOT stored if:
  # - The request method is not GET (non idempotent)
  # - The request is handled by a Devise controller such as
  #   Devise::SessionsController as that could cause an
  #   infinite redirect loop.
  # - The request is an Ajax request as this can lead to very<commit_msg>fix bug with invalid csrf tokens<commit_after># ApplicationController
class ApplicationController < ActionController::Base
  before_action :store_user_location!, if: :storable_location?
  # The callback which stores the current location must be added before you
  # authenticate the user as `authenticate_user!` (or whatever your resource is)
  # will halt the filter chain and redirect before the location can be stored.
  before_action :authenticate_user!
  before_action :set_locale

  # show error message if authorization with cancancan fails
  rescue_from CanCan::AccessDenied do |exception|
    redirect_to main_app.root_url, alert: exception.message
  end

  rescue_from ActionController::InvalidAuthenticityToken do
    redirect_to main_app.root_url,
      alert: "Deine Sitzung ist abgelaufen. Bitte melde Dich wieder an."
  end

  # determine where to send the user after login
  def after_sign_in_path_for(resource_or_scope)
    # checks if user consented to DSGVO and has ever edited his/her profile
    # if profile was never edited, redirect to profil editing
    stored_location_for(resource_or_scope) || super
  end

  private

  # It's important that the location is NOT stored if:
  # - The request method is not GET (non idempotent)
  # - The request is handled by a Devise controller such as
  #   Devise::SessionsController as that could cause an
  #   infinite redirect loop.
  # - The request is an Ajax request as this can lead to very
{'fraction_non_alphanumeric': 0.048055759354365374, 'fraction_numerical': 0.0, 'mean_word_length': 4.347058823529411, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1201806', 'n_tokens_mistral': 755, 'n_tokens_neox': 735, 'n_words': 316}