1 class OauthToken < ActiveRecord::Base
2 belongs_to :client_application
5 scope :authorized, -> { where("authorized_at IS NOT NULL and invalidated_at IS NULL") }
7 validates :token, :presence => true, :uniqueness => true
8 validates :user, :associated => true
9 validates :client_application, :presence => true
11 before_validation :generate_keys, :on => :create
18 update_attributes(:invalidated_at => Time.now)
22 !authorized_at.nil? && !invalidated?
26 "oauth_token=#{token}&oauth_token_secret=#{secret}"
32 self.token = OAuth::Helper.generate_key(40)[0, 40]
33 self.secret = OAuth::Helper.generate_key(40)[0, 40]