<commit_before># frozen_string_literal: true

module AuthenticationStrategies
  # Handle successful OAuth authentication
  class OmniauthCallbacksController < Devise::OmniauthCallbacksController
    include MagicLink

    before_action :set_authentication_strategy, except: [:failure]
    before_action :set_reader, except: [:failure]

    # @route [GET, POST] `/authentication_strategies/auth/google/callback`
    def google
      if @authentication_strategy.persisted?
        sign_in @reader
        link_reader if following_magic_link?
        redirect_to after_linking_redirect_path || root_path
      else
        session['devise.google_data'] = request.env['omniauth.auth']
                                               .except(:extra)
        render 'devise/registrations/new', layout: 'window'
      end
    end

    # @route [GET, POST] `/authentication_strategies/auth/lti/callback`
    def lti
      if @authentication_strategy.persisted?
        sign_in @reader<commit_msg>fix: don’t require a csrf token in OmniauthCallbacks (#249)<commit_after># frozen_string_literal: true

module AuthenticationStrategies
  # Handle successful OAuth authentication
  class OmniauthCallbacksController < Devise::OmniauthCallbacksController
    include MagicLink

    skip_before_action :verify_authenticity_token
    before_action :set_authentication_strategy, except: [:failure]
    before_action :set_reader, except: [:failure]

    # @route [GET, POST] `/authentication_strategies/auth/google/callback`
    def google
      if @authentication_strategy.persisted?
        sign_in @reader
        link_reader if following_magic_link?
        redirect_to after_linking_redirect_path || root_path
      else
        session['devise.google_data'] = request.env['omniauth.auth']
                                               .except(:extra)
        render 'devise/registrations/new', layout: 'window'
      end
    end

    # @route [GET, POST] `/authentication_strategies/auth/lti/callback`
    def lti
      if @authentication_strategy.persisted?
        sign_in @reader
{'fraction_non_alphanumeric': 0.0782608695652174, 'fraction_numerical': 0.0014492753623188406, 'mean_word_length': 3.2179226069246436, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6274307', 'n_tokens_mistral': 601, 'n_tokens_neox': 580, 'n_words': 125}