Use SecureRandom to generate user tokens

This commit is contained in:
Tom Hughes
2023-12-04 17:23:23 +00:00
parent 5bd9a2faef
commit 12b4d11d44
2 changed files with 9 additions and 16 deletions

View File

@ -502,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