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 attr_accessible :nonce, :timestamp
9 # Remembers a nonce and it's associated timestamp. It returns false if it has already been used
10 def self.remember(nonce, timestamp)
11 oauth_nonce = OauthNonce.create(:nonce => nonce, :timestamp => timestamp)
12 return false if oauth_nonce.new_record?