]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Various updates to the user management, including the creation of a
[rails.git] / lib / osm.rb
index 5f31e31bf3f83f2b232cd1687c0c7b6657d19bff..ea2a581645d797e7fd677cf31629863f569b2967 100644 (file)
@@ -391,4 +391,16 @@ module OSM
   rescue Exception
     return nil
   end
+
+  # Construct a random token of a given length
+  def self.make_token(length = 30)
+    chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
+    token = ''
+
+    length.times do
+      token += chars[(rand * chars.length).to_i].chr
+    end
+
+    return token
+  end
 end