]> git.openstreetmap.org Git - rails.git/blob - app/models/oauth_nonce.rb
Generate a new style links for node locations in the data browser
[rails.git] / app / models / oauth_nonce.rb
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
6
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?
11     oauth_nonce
12   end
13 end