Module: OAuth2::Provider::Models::TokenExpiry

Extended by:
ActiveSupport::Concern
Defined in:
lib/oauth2/provider/models.rb

Instance Method Summary collapse

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/oauth2/provider/models.rb', line 28

def expired?
  self.expires_at && self.expires_at < Time.now
end

#expires_inObject



32
33
34
35
36
37
38
# File 'lib/oauth2/provider/models.rb', line 32

def expires_in
  if expired?
    0
  else
    self.expires_at.to_i - Time.now.to_i
  end
end

#fresh?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/oauth2/provider/models.rb', line 24

def fresh?
  !expired?
end

#initialize(*args, &block) ⇒ Object



17
18
19
20
21
22
# File 'lib/oauth2/provider/models.rb', line 17

def initialize(*args, &block)
  super
  if default_token_lifespan
    self.expires_at ||= default_token_lifespan.from_now
  end
end