<commit_before>require 'jwt'

module Satellite
  class JWTUserDecoder
    attr_reader :token

    def initialize(token)
      @token = token
    end

    def payload
      @payload ||= ::JWT.decode(token, Satellite.configuration.jwt_secret_key_base).first
    end

    def user
      ::User.find_by(uid: user_uid)
    end

    def user_uid
      payload["id"]
    end
  end
end<commit_msg>the decoder can be called with an non existing token<commit_after>require 'jwt'

module Satellite
  class JWTUserDecoder
    attr_reader :token

    def initialize(token)
      @token = token
    end

    def payload
      return {} unless token.present?
      @payload ||= ::JWT.decode(token, Satellite.configuration.jwt_secret_key_base).first
    end

    def user
      ::User.find_by(uid: user_uid)
    end

    def user_uid
      payload["id"]
    end
  end
end
{'fraction_non_alphanumeric': 0.08187134502923976, 'fraction_numerical': 0.0, 'mean_word_length': 2.705627705627706, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3083255', 'n_tokens_mistral': 284, 'n_tokens_neox': 270, 'n_words': 71}