Class: Userbin::TokenStore

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

Instance Method Summary collapse

Constructor Details

#initialize(cookies) ⇒ TokenStore

Returns a new instance of TokenStore


3
4
5
# File 'lib/userbin/token_store.rb', line 3

def initialize(cookies)
  @cookies = cookies
end

Instance Method Details

#session_tokenObject


7
8
9
10
# File 'lib/userbin/token_store.rb', line 7

def session_token
  token = @cookies['_ubs']
  Userbin::SessionToken.new(token) if token
end

#session_token=(value) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/userbin/token_store.rb', line 12

def session_token=(value)
  @cookies['_ubs'] = value

  if value && value != @cookies['_ubs']
    @cookies['_ubs']
  elsif !value
    @cookies['_ubs'] = nil
  end
end

#trusted_device_tokenObject


22
23
24
# File 'lib/userbin/token_store.rb', line 22

def trusted_device_token
  @cookies['_ubt']
end

#trusted_device_token=(value) ⇒ Object


26
27
28
# File 'lib/userbin/token_store.rb', line 26

def trusted_device_token=(value)
  @cookies['_ubt'] = value
end