X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/124909a64c4c2b739cebfff69fcf100e6b6d2457..12b4d11d44055399085bf1d10136ffbe4255bcbe:/lib/osm.rb?ds=sidebyside diff --git a/lib/osm.rb b/lib/osm.rb index 6d945c4fe..c7f8bef2f 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -355,6 +355,10 @@ module OSM # Raised when a rate limit is exceeded class APIRateLimitExceeded < APIError + def initialize + super "Rate limit exceeded" + end + def status :too_many_requests end @@ -498,15 +502,8 @@ module OSM end # Construct a random token of a given length - def self.make_token(length = 30) - chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - token = "" - - length.times do - token += chars[(rand * chars.length).to_i].chr - end - - token + def self.make_token(length = 24) + SecureRandom.urlsafe_base64(length) end # Return an SQL fragment to select a given area of the globe