<commit_before>module Devise
  module Strategies
    class Sandstorm < Authenticatable
      def authenticate!
        Rails.logger.info 'Authenticating Sandstorm'
        userid = request.headers['HTTP_X_SANDSTORM_USER_ID'].encode(Encoding::UTF_8)
        username = URI.unescape(request.headers['HTTP_X_SANDSTORM_USERNAME']).force_encoding(Encoding::UTF_8)
        u = User.where(username: userid).first
        if !u
          opts = {}
          opts[:name] = username
          opts[:password] = "<PASSWORD>"
          opts[:username] = userid
          opts[:email] = userid + "@example.com"
          u = User.new(opts)
          u.generate_password
          u.generate_reset_token
          u.skip_confirmation!
          if u.save
            Rails.logger.info 'User was successfully created.'
          else
            Rails.logger.error 'User could not be created'
            Rails.logger.error u.errors
          end
        end

        permission_list = request.headers["HTTP_X_SANDSTORM_PERMISSIONS"].split(',')
        if (permission_list.include? 'admin') && !u.admin
          u.admin = true
          u.save
        end

        Rails.logger.info 'Done Authenticating Sandstorm'
        success!(u)
      end
      def valid?
        !!request.headers['HTTP_X_SANDSTORM_USER_ID']
      end
    end
  end
end
<commit_msg>always hide the ssh warning<commit_after>module Devise
  module Strategies
    class Sandstorm < Authenticatable
      def authenticate!
        Rails.logger.info 'Authenticating Sandstorm'
        userid = request.headers['HTTP_X_SANDSTORM_USER_ID'].encode(Encoding::UTF_8)
        username = URI.unescape(request.headers['HTTP_X_SANDSTORM_USERNAME']).force_encoding(Encoding::UTF_8)
        u = User.where(username: userid).first
        if !u
          opts = {}
          opts[:name] = username
          opts[:password] = "<PASSWORD>"
          opts[:username] = userid
          opts[:email] = userid + "@example.com"
          opts[:hide_no_ssh_key] = true
          u = User.new(opts)
          u.generate_password
          u.generate_reset_token
          u.skip_confirmation!
          if u.save
            Rails.logger.info 'User was successfully created.'
          else
            Rails.logger.error 'User could not be created'
            Rails.logger.error u.errors
          end
        end

        permission_list = request.headers["HTTP_X_SANDSTORM_PERMISSIONS"].split(',')
        if (permission_list.include? 'admin') && !u.admin
          u.admin = true
          u.save
        end

        Rails.logger.info 'Done Authenticating Sandstorm'
        success!(u)
      end
      def valid?
        !!request.headers['HTTP_X_SANDSTORM_USER_ID']
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09642074506939372, 'fraction_numerical': 0.0014609203798392988, 'mean_word_length': 2.0914221218961626, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '5924521', 'n_tokens_mistral': 811, 'n_tokens_neox': 802, 'n_words': 160}