]> git.openstreetmap.org Git - rails.git/blob - app/models/oauth_nonce.rb
Fix some rubocop warnings
[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 :timestamp, :presence => true
5   validates :nonce, :presence => true, :uniqueness => { :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