X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/908a6ef409518d86bfd2cdf0d2a82a6c312821c8..95d899786a1bbabacc0cd12ef1c4814118d9d0de:/app/models/oauth_token.rb?ds=sidebyside diff --git a/app/models/oauth_token.rb b/app/models/oauth_token.rb index f64ec53db..376ad7644 100644 --- a/app/models/oauth_token.rb +++ b/app/models/oauth_token.rb @@ -1,9 +1,13 @@ class OauthToken < ActiveRecord::Base belongs_to :client_application belongs_to :user + + scope :authorized, where("authorized_at IS NOT NULL and invalidated_at IS NULL") + validates_uniqueness_of :token validates_presence_of :client_application, :token, :secret - before_validation_on_create :generate_keys + + before_validation :generate_keys, :on => :create def self.find_token(token_key) token = OauthToken.find_by_token(token_key, :include => :client_application)