pelle / oauth-plugin

Rails plugin for OAuth
http://stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails
MIT License
716 stars 216 forks source link

Mongoid Issue with @provider.find_by_key etc #28

Closed kuruma-gs closed 13 years ago

kuruma-gs commented 13 years ago

The issue is same https://github.com/pelle/oauth-plugin/issues/closed/#issue/27

lib/oauth/controllers/application_controller_methods.rb 80 @oauth2_token = Oauth2Token.find_by_token(token) 139 @client_application = ClientApplication.find_by_key(request_proxy.consumer_key)

lib/oauth/controllers/provider_controller.rb 35 @client_application = ClientApplication.find_by_key params[:client_id] 53 @token = ::RequestToken.find_by_token params[:oauth_token] 61 @token = current_user.tokens.find_by_token params[:token] 122 @client_application = ClientApplication.find_by_key params[:client_id] 152 @client_application = ClientApplication.find_by_key params[:client_id] 182 @verification_code = @client_application.oauth2_verifiers.find_by_token params[:code]

Mongoid does not recognise this. undefined method find_by_xxx....

Solution is to override or change this line to find(:first,:conditions=>{:xxx=>....}) or where(:xxx=>...).first

imack commented 13 years ago

I had this one too. There seems to be a few places where you need to patch in order to make it work with mongoid. (or at least from mongoid 2 from what I see)

imack commented 13 years ago

The bulk of which I were able to find fixes for here: http://unhandledexpression.com/2011/06/02/rails-and-oauth-plugin-part-1-the-provider/

arnklint commented 12 years ago

Here is what I did to fix it, exactly as you pointed out @imackinn : https://github.com/arnklint/oauth-plugin/commit/55f4728c7de451f560c8b02854bc2225e5213f97 Ran the tests, and they are all fine with this change.