From 55f4728c7de451f560c8b02854bc2225e5213f97 Mon Sep 17 00:00:00 2001 From: Jonas Arnklint Date: Tue, 27 Dec 2011 15:17:35 +0100 Subject: [PATCH] Mongoid adaptions --- lib/oauth/controllers/provider_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/oauth/controllers/provider_controller.rb b/lib/oauth/controllers/provider_controller.rb index e47227ae..ae53a3bf 100644 --- a/lib/oauth/controllers/provider_controller.rb +++ b/lib/oauth/controllers/provider_controller.rb @@ -33,7 +33,7 @@ def access_token end def token - @client_application = ClientApplication.find_by_key! params[:client_id] + @client_application = ClientApplication.where(:key => params[:client_id]).first if @client_application.secret != params[:client_secret] oauth2_error "invalid_client" return @@ -54,21 +54,21 @@ def test_request def authorize if params[:oauth_token] - @token = ::RequestToken.find_by_token! params[:oauth_token] + @token = ::RequestToken.where(:token => params[:oauth_token]).first oauth1_authorize else if request.post? @authorizer = OAuth::Provider::Authorizer.new current_user, user_authorizes_token?, params redirect_to @authorizer.redirect_uri else - @client_application = ClientApplication.find_by_key! params[:client_id] + @client_application = ClientApplication.where(:key => params[:client_id]).first render :action => "oauth2_authorize" end end end def revoke - @token = current_user.tokens.find_by_token! params[:token] + @token = current_user.tokens.where(:token => params[:token]).first if @token @token.invalidate! flash[:notice] = "You've revoked the token for #{@token.client_application.name}" @@ -132,7 +132,7 @@ def oauth1_authorize # http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.1.1 def oauth2_token_authorization_code - @verification_code = @client_application.oauth2_verifiers.find_by_token params[:code] + @verification_code = @client_application.oauth2_verifiers.where(:token => params[:code]).first unless @verification_code oauth2_error return