Sha256: 65ebc1c2a1335a5d8f53ce9c968318cd959cf416b8634a7e24d3c0fbe52aac44
Contents?: true
Size: 755 Bytes
Versions: 2
Compression:
Stored size: 755 Bytes
Contents
module Skydrive class Token < ActiveRecord::Base validates :user_id, uniqueness: true belongs_to :user def requires_refresh? !!(self.not_before && !self.not_before.is_a?(Time) && self.not_before < Time.now) end def is_valid? !!self.access_token && self.expires_on && self.expires_on > Time.now end def refresh! results = {} results = self.user.skydrive_client.update_api_tokens(resource: resource, refresh_token: refresh_token, token: access_token) if results.key? 'access_token' attrs = ['token_type', 'expires_in', 'expires_on', 'not_before', 'resource', 'access_token', 'refresh_token'] update_attributes(results.reject{|a| !attrs.include?(a)}) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lti_skydrive-1.2.2 | app/models/skydrive/token.rb |
lti_skydrive-1.2.1 | app/models/skydrive/token.rb |