Class: Userbin::SessionToken

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

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ SessionToken

Returns a new instance of SessionToken.



5
6
7
8
9
# File 'lib/userbin/session_token.rb', line 5

def initialize(token)
  if token
    @jwt = Userbin::JWT.new(token)
  end
end

Instance Method Details

#device_trusted?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/userbin/session_token.rb', line 19

def device_trusted?
  @jwt.payload['tru'] == 1
end

#expired?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/userbin/session_token.rb', line 15

def expired?
  @jwt.expired?
end

#has_default_pairing?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/userbin/session_token.rb', line 23

def has_default_pairing?
  @jwt.payload['dpr'] > 0
end

#mfa_enabled?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/userbin/session_token.rb', line 27

def mfa_enabled?
  @jwt.payload['mfa'] == 1
end

#mfa_in_progress?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/userbin/session_token.rb', line 31

def mfa_in_progress?
  @jwt.payload['chg'] == 1
end

#mfa_required?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/userbin/session_token.rb', line 35

def mfa_required?
  @jwt.payload['vfy'] > 0
end

#to_sObject



11
12
13
# File 'lib/userbin/session_token.rb', line 11

def to_s
  @jwt.to_token
end