Class: Aurora::Server::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/aurora/server/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, pass, lifetime = 5*60) ⇒ Token

Takes the lifetime of the token



16
17
18
19
20
21
22
# File 'lib/aurora/server/token.rb', line 16

def initialize(user, pass, lifetime=5*60)
  @lifetime = lifetime
  @token = Digest::MD5.hexdigest("#{user}:#{pass}").split(/(....)/)[1..-1].map{|node|node="-" if node==""; node}.to_s.upcase
  
  @@tokens ||= []
  @@tokens << self
end

Instance Attribute Details

#lifetimeObject

– Constants and Attributes ++



9
10
11
# File 'lib/aurora/server/token.rb', line 9

def lifetime
  @lifetime
end

#tokenObject

– Constants and Attributes ++



9
10
11
# File 'lib/aurora/server/token.rb', line 9

def token
  @token
end

Instance Method Details

#to_jsonObject

Creates JSON format of Token



25
26
27
28
29
30
# File 'lib/aurora/server/token.rb', line 25

def to_json
  {
    :token => @token,
    :lifetime => @lifetime
  }.to_json
end