Sha256: 7b2ad494200cf8e83e20da90ab6b46db2a359c49330e8259dc3c56bc6db37a2a

Contents?: true

Size: 485 Bytes

Versions: 8

Compression:

Stored size: 485 Bytes

Contents

module Doorkeeper
  module OAuth
    module Helpers
      module UniqueToken
        def self.generate_for(attribute, klass, options = {})
          generator_method = options.delete(:generator) || SecureRandom.method(:hex)
          token_size       = options.delete(:size)      || 32
          loop do
            token = generator_method.call(token_size)
            break token unless klass.send("find_by_#{attribute}", token)
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
doorkeeper-0.4.2 lib/doorkeeper/oauth/helpers/unique_token.rb
doorkeeper-0.4.1 lib/doorkeeper/oauth/helpers/unique_token.rb
doorkeeper-0.4.0 lib/doorkeeper/oauth/helpers/unique_token.rb
doorkeeper-0.3.4 lib/doorkeeper/oauth/helpers/unique_token.rb
doorkeeper-0.3.3 lib/doorkeeper/oauth/helpers/unique_token.rb
doorkeeper-0.3.2 lib/doorkeeper/oauth/helpers/unique_token.rb
doorkeeper-0.3.1 lib/doorkeeper/oauth/helpers/unique_token.rb
doorkeeper-0.3.0 lib/doorkeeper/oauth/helpers/unique_token.rb