<commit_before>module Sorcery
  module Model
    # This module encapsulates the logic for temporary token.
    # A temporary token is created to identify a user in scenarios 
    # such as reseting password and activating the user by email.
    module TemporaryToken
      def self.included(base)
        base.extend(ClassMethods)
      end
      
      # Random code, used for salt and temporary tokens.
      def self.generate_random_token
        Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
      end
      
      module ClassMethods
        def load_from_token(token, token_attr_name, token_expiration_date_attr)
          return nil if token.blank?
          user = find_by_sorcery_token(token_attr_name,token)
          if !user.blank? && !user.send(token_expiration_date_attr).nil?
            return Time.now.utc < user.send(token_expiration_date_attr) ? user : nil
          end
          user
        end
      end
    end
  end
end<commit_msg>changing temp_token generation to be same as devise, hopefully fixes #19<commit_after>require 'securerandom'

module Sorcery
  module Model
    # This module encapsulates the logic for temporary token.
    # A temporary token is created to identify a user in scenarios 
    # such as reseting password and activating the user by email.
    module TemporaryToken
      def self.included(base)
        base.extend(ClassMethods)
      end
      
      # Random code, used for salt and temporary tokens.
      def self.generate_random_token
        SecureRandom.base64(15).tr('+/=lIO0', 'pqrsxyz')
      end
      
      module ClassMethods
        def load_from_token(token, token_attr_name, token_expiration_date_attr)
          return nil if token.blank?
          user = find_by_sorcery_token(token_attr_name,token)
          if !user.blank? && !user.send(token_expiration_date_attr).nil?
            return Time.now.utc < user.send(token_expiration_date_attr) ? user : nil
          end
          user
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06330365974282888, 'fraction_numerical': 0.003956478733926805, 'mean_word_length': 2.5060658578856154, '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': '804433', 'n_tokens_mistral': 590, 'n_tokens_neox': 571, 'n_words': 170}