Class: Teams::Auth::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/teams/auth/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Token

Returns a new instance of Token.



11
12
13
14
# File 'lib/teams/auth/token.rb', line 11

def initialize(value)
  @value = value
  @payload = decode_payload(value)
end

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload.



9
10
11
# File 'lib/teams/auth/token.rb', line 9

def payload
  @payload
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/teams/auth/token.rb', line 9

def value
  @value
end

Instance Method Details

#expired?(skew: 60) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/teams/auth/token.rb', line 16

def expired?(skew: 60)
  exp = payload["exp"]
  return false unless exp

  Time.now.to_i >= exp.to_i - skew
end