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_uniqueness_of :token
8 validates_presence_of :client_application, :token
10 before_validation :generate_keys, :on => :create
17 update_attributes(:invalidated_at => Time.now)
21 !authorized_at.nil? && !invalidated?
25 "oauth_token=#{token}&oauth_token_secret=#{secret}"
31 self.token = OAuth::Helper.generate_key(40)[0, 40]
32 self.secret = OAuth::Helper.generate_key(40)[0, 40]