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
18 :invalidated_at => Time.now
19 }, :without_protection => true)
23 authorized_at != nil && !invalidated?
27 "oauth_token=#{token}&oauth_token_secret=#{secret}"
33 self.token = OAuth::Helper.generate_key(40)[0,40]
34 self.secret = OAuth::Helper.generate_key(40)[0,40]