Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't try and use client_application if we didn't find it #143

Open
wants to merge 1 commit into from

1 participant

This page is out of date. Refresh to see the latest.
Showing with 12 additions and 7 deletions.
  1. +12 −7 lib/oauth/rack/oauth_filter.rb
View
19 lib/oauth/rack/oauth_filter.rb
@@ -35,17 +35,22 @@ def call(env)
client_application = ClientApplication.find_by_key(request_proxy.consumer_key)
env["oauth.client_application_candidate"] = client_application
- # Store this temporarily in client_application object for use in request token generation
- client_application.token_callback_url = request_proxy.oauth_callback if request_proxy.oauth_callback
oauth_token = nil
- if request_proxy.token
- oauth_token = client_application.tokens.where('invalidated_at IS NULL AND authorized_at IS NOT NULL and token = ?', request_proxy.token).first
- if oauth_token.respond_to?(:provided_oauth_verifier=)
- oauth_token.provided_oauth_verifier = request_proxy.oauth_verifier
+ if client_application
+ # Store this temporarily in client_application object for use in request token generation
+ client_application.token_callback_url = request_proxy.oauth_callback if request_proxy.oauth_callback
+
+ if request_proxy.token
+ oauth_token = client_application.tokens.where('invalidated_at IS NULL AND authorized_at IS NOT NULL and token = ?', request_proxy.token).first
+ oauth_token = client_application.tokens.first(:conditions => ['invalidated_at IS NULL AND authorized_at IS NOT NULL and token = ?', request_proxy.token])
+ if oauth_token.respond_to?(:provided_oauth_verifier=)
+ oauth_token.provided_oauth_verifier = request_proxy.oauth_verifier
+ end
+ env["oauth.token_candidate"] = oauth_token
end
- env["oauth.token_candidate"] = oauth_token
end
+
# return the token secret and the consumer secret
[(oauth_token.nil? ? nil : oauth_token.secret), (client_application.nil? ? nil : client_application.secret)]
end
Something went wrong with that request. Please try again.