Sha256: 0da1858f986514a13d10793fa050f5bed0175efc4894e1284039a7eb0c657710
Contents?: true
Size: 1006 Bytes
Versions: 12
Compression:
Stored size: 1006 Bytes
Contents
class OauthToken include Mongoid::Document include Mongoid::Timestamps field :token, :type => String field :secret, :type => String field :callback_url, :type => String field :verifier, :type => String field :scope, :type => String field :authorized_at, :type => Time field :invalidated_at, :type => Time field :valid_to, :type => Time index :token, :unique => true referenced_in :user referenced_in :client_application validates_uniqueness_of :token validates_presence_of :client_application, :token before_validation :generate_keys, :on => :create def invalidated? !invalidated_at.nil? end def invalidate! update_attribute(:invalidated_at, Time.now) end def authorized? !authorized_at.nil? && !invalidated? end def to_query "oauth_token=#{token}&oauth_token_secret=#{secret}" end protected def generate_keys self.token = OAuth::Helper.generate_key(40)[0,40] self.secret = OAuth::Helper.generate_key(40)[0,40] end end
Version data entries
12 entries across 12 versions & 3 rubygems