Module: JunglePath::Authentication::Helpers

Defined in:
lib/jungle_path/authentication/helpers.rb

Class Method Summary collapse

Class Method Details

.expires_in_timestamp(days: 0, hours: 0, minutes: 0, seconds: 0) ⇒ Object



13
14
15
16
# File 'lib/jungle_path/authentication/helpers.rb', line 13

def self.expires_in_timestamp(days: 0, hours: 0, minutes: 0, seconds: 0)
  s = seconds + (minutes * 60) + (hours * 60 * 60) + (days * 24 * 60 * 60)
  expires_timestamp = Time.new + s
end

.generate_api_key(prefix = "sk_") ⇒ Object



6
7
8
9
10
11
# File 'lib/jungle_path/authentication/helpers.rb', line 6

def self.generate_api_key(prefix="sk_")
  begin
    key = SecureRandom.urlsafe_base64(18)
  end while key.include? ?_
  key = prefix + key
end