cartodb/app/models/carto/helpers/auth_token_generator.rb

20 lines
345 B
Ruby
Raw Normal View History

2020-06-15 10:58:47 +08:00
module Carto
module AuthTokenGenerator
def get_auth_token
auth_token || generate_and_save_auth_token
end
private
def generate_and_save_auth_token
self.auth_token = generate_auth_token
save
auth_token
end
def generate_auth_token
SecureRandom.urlsafe_base64(nil, false)
end
end
end