]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/client_application.rb
Switch to using oauth-plugin as a gem
[rails.git] / app / models / client_application.rb
index d3799abe00a483db593d68ef2e6bc4e8d07c4de0..2186dc5dfc367abf152b824d9a44c6b02bc20615 100644 (file)
@@ -6,6 +6,16 @@ class ClientApplication < ActiveRecord::Base
   validates_uniqueness_of :key
   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 self.verify_request(request, options = {}, &block)
     begin
       signature = OAuth::Signature.build(request, options, &block)