]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/oauth_token.rb
Revert "Switch to using oauth-plugin as a gem"
[rails.git] / app / models / oauth_token.rb
index 5fca40ce203e425965a59a222615976cf70eb5e4..f64ec53dbaf4869712d0b2bd1abc1f19a1dd1870 100644 (file)
@@ -5,6 +5,16 @@ class OauthToken < ActiveRecord::Base
   validates_presence_of :client_application, :token, :secret
   before_validation_on_create :generate_keys
   
   validates_presence_of :client_application, :token, :secret
   before_validation_on_create :generate_keys
   
+  def self.find_token(token_key)
+    token = OauthToken.find_by_token(token_key, :include => :client_application)
+    if token && token.authorized?
+      logger.info "Loaded #{token.token} which was authorized by (user_id=#{token.user_id}) on the #{token.authorized_at}"
+      token
+    else
+      nil
+    end
+  end
+  
   def invalidated?
     invalidated_at != nil
   end
   def invalidated?
     invalidated_at != nil
   end