<commit_before>module Descartes
  class Web < Sinatra::Base

    configure do
      enable :logging if Config.rack_env.eql?("production")
      disable :raise_errors if Config.rack_env.eql?("production")
      disable :show_exceptions if Config.rack_env.eql?("production")
      use Rack::SslEnforcer if Config.force_https
    end

    before do
      if !(request.path_info =~ /\/auth/)
        if !(api_token? && request.accept.include?("application/json"))
          if !current_user
            session.clear
            session['redirect_to'] = request.path_info
            redirect '/auth/unauthorized'
          end
        end
      end
    end
<commit_msg>find our User and add preferences to session, refs #87<commit_after>module Descartes
  class Web < Sinatra::Base

    configure do
      enable :logging if Config.rack_env.eql?("production")
      disable :raise_errors if Config.rack_env.eql?("production")
      disable :show_exceptions if Config.rack_env.eql?("production")
      use Rack::SslEnforcer if Config.force_https
    end

    before do
      if !(request.path_info =~ /\/auth/)
        if !(api_token? && request.accept.include?("application/json"))
          if !current_user
            session.clear
            session['redirect_to'] = request.path_info
            redirect '/auth/unauthorized'
          else
            session['user']['preferences'] = User.find_or_create_by_email(session['user']['email']).preferences
          end
        end
      end
    end

{'fraction_non_alphanumeric': 0.10733333333333334, 'fraction_numerical': 0.0013333333333333333, 'mean_word_length': 2.523474178403756, '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': '2242069', 'n_tokens_mistral': 440, 'n_tokens_neox': 432, 'n_words': 98}