1 # Simple store of nonces. The OAuth Spec requires that any given pair of nonce and timestamps are unique.
 
   2 # Thus you can use the same nonce with a different timestamp and viceversa.
 
   3 class OauthNonce < ActiveRecord::Base
 
   4   validates_presence_of :nonce, :timestamp
 
   5   validates_uniqueness_of :nonce, :scope => :timestamp
 
   7   # Remembers a nonce and it's associated timestamp. It returns false if it has already been used
 
   8   def self.remember(nonce, timestamp)
 
   9     oauth_nonce = OauthNonce.create(:nonce => nonce, :timestamp => timestamp)
 
  10     return false if oauth_nonce.new_record?