Class: Uservoice::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/uservoice_sso.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/uservoice_sso.rb', line 8

def data
  @data
end

Class Method Details

.generate(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/uservoice_sso.rb', line 10

def self.generate(options = {})
  options.merge!({expires: (Time.zone.now.utc+5*60).to_s})

  key = EzCrypto::Key.with_password ::Configuration[:uservoice_subdomain], ::Configuration[:uservoice_sso_key]
  encrypted = key.encrypt(options.to_json)
  @data = Base64.encode64(encrypted).gsub(/\n/, '')

  @data.to_s
end