X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/17f4e58e46b42e2b21704ff3293388ea9c11c77d..8ae5d94b2f16d6f2cf1739e19ebc3793a18a0a4a:/app/models/oauth_token.rb diff --git a/app/models/oauth_token.rb b/app/models/oauth_token.rb index c45a3d569..376ad7644 100644 --- a/app/models/oauth_token.rb +++ b/app/models/oauth_token.rb @@ -1,8 +1,12 @@ 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 :generate_keys, :on => :create def self.find_token(token_key)