From d4ae78d35a600f4f43e42185620dde8a3733253f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Re=CC=81mond?= Date: Sat, 1 Feb 2014 17:55:39 -0800 Subject: [PATCH] Avoid name clash #144 --- generators/oauth_provider/templates/oauth2_token.rb | 2 +- generators/oauth_provider/templates/oauth2_token_spec.rb | 4 ++-- generators/oauth_provider/templates/oauth2_verifier.rb | 2 +- .../active_record/oauth_provider_templates/oauth2_token.rb | 2 +- .../oauth_provider_templates/oauth2_verifier.rb | 2 +- .../mongoid/oauth_provider_templates/oauth2_token.rb | 2 +- .../mongoid/oauth_provider_templates/oauth2_verifier.rb | 2 +- lib/generators/rspec/templates/oauth2_token_spec.rb | 4 ++-- lib/oauth/controllers/provider_controller.rb | 4 ++-- lib/oauth/provider/authorizer.rb | 2 +- lib/oauth/rack/oauth_filter.rb | 2 +- spec/dummy_provider_models.rb | 2 +- spec/oauth/provider/authorizer_spec.rb | 6 +++--- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/generators/oauth_provider/templates/oauth2_token.rb b/generators/oauth_provider/templates/oauth2_token.rb index abc71770..1d64ecfe 100644 --- a/generators/oauth_provider/templates/oauth2_token.rb +++ b/generators/oauth_provider/templates/oauth2_token.rb @@ -1,4 +1,4 @@ -class Oauth2Token < AccessToken +class Oauth2ProviderToken < AccessToken attr_accessor :state def as_json(options={}) d = {:access_token=>token, :token_type => 'bearer'} diff --git a/generators/oauth_provider/templates/oauth2_token_spec.rb b/generators/oauth_provider/templates/oauth2_token_spec.rb index 1ad6baef..43736c89 100644 --- a/generators/oauth_provider/templates/oauth2_token_spec.rb +++ b/generators/oauth_provider/templates/oauth2_token_spec.rb @@ -1,9 +1,9 @@ require File.dirname(__FILE__) + '/../spec_helper' -describe Oauth2Token do +describe Oauth2ProviderToken do fixtures :client_applications, :users, :oauth_tokens before(:each) do - @token = Oauth2Token.create :client_application => client_applications(:one), :user=>users(:aaron) + @token = Oauth2ProviderToken.create :client_application => client_applications(:one), :user=>users(:aaron) end it "should be valid" do diff --git a/generators/oauth_provider/templates/oauth2_verifier.rb b/generators/oauth_provider/templates/oauth2_verifier.rb index 09b7cf7f..fcc966ff 100644 --- a/generators/oauth_provider/templates/oauth2_verifier.rb +++ b/generators/oauth_provider/templates/oauth2_verifier.rb @@ -4,7 +4,7 @@ class Oauth2Verifier < OauthToken def exchange!(params={}) OauthToken.transaction do - token = Oauth2Token.create! :user=>user,:client_application=>client_application, :scope => scope + token = Oauth2ProviderToken.create! :user=>user,:client_application=>client_application, :scope => scope invalidate! token end diff --git a/lib/generators/active_record/oauth_provider_templates/oauth2_token.rb b/lib/generators/active_record/oauth_provider_templates/oauth2_token.rb index abc71770..1d64ecfe 100644 --- a/lib/generators/active_record/oauth_provider_templates/oauth2_token.rb +++ b/lib/generators/active_record/oauth_provider_templates/oauth2_token.rb @@ -1,4 +1,4 @@ -class Oauth2Token < AccessToken +class Oauth2ProviderToken < AccessToken attr_accessor :state def as_json(options={}) d = {:access_token=>token, :token_type => 'bearer'} diff --git a/lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb b/lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb index 09b7cf7f..fcc966ff 100644 --- a/lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb +++ b/lib/generators/active_record/oauth_provider_templates/oauth2_verifier.rb @@ -4,7 +4,7 @@ class Oauth2Verifier < OauthToken def exchange!(params={}) OauthToken.transaction do - token = Oauth2Token.create! :user=>user,:client_application=>client_application, :scope => scope + token = Oauth2ProviderToken.create! :user=>user,:client_application=>client_application, :scope => scope invalidate! token end diff --git a/lib/generators/mongoid/oauth_provider_templates/oauth2_token.rb b/lib/generators/mongoid/oauth_provider_templates/oauth2_token.rb index abc71770..1d64ecfe 100644 --- a/lib/generators/mongoid/oauth_provider_templates/oauth2_token.rb +++ b/lib/generators/mongoid/oauth_provider_templates/oauth2_token.rb @@ -1,4 +1,4 @@ -class Oauth2Token < AccessToken +class Oauth2ProviderToken < AccessToken attr_accessor :state def as_json(options={}) d = {:access_token=>token, :token_type => 'bearer'} diff --git a/lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb b/lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb index 09b7cf7f..fcc966ff 100644 --- a/lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb +++ b/lib/generators/mongoid/oauth_provider_templates/oauth2_verifier.rb @@ -4,7 +4,7 @@ class Oauth2Verifier < OauthToken def exchange!(params={}) OauthToken.transaction do - token = Oauth2Token.create! :user=>user,:client_application=>client_application, :scope => scope + token = Oauth2ProviderToken.create! :user=>user,:client_application=>client_application, :scope => scope invalidate! token end diff --git a/lib/generators/rspec/templates/oauth2_token_spec.rb b/lib/generators/rspec/templates/oauth2_token_spec.rb index 1ad6baef..43736c89 100644 --- a/lib/generators/rspec/templates/oauth2_token_spec.rb +++ b/lib/generators/rspec/templates/oauth2_token_spec.rb @@ -1,9 +1,9 @@ require File.dirname(__FILE__) + '/../spec_helper' -describe Oauth2Token do +describe Oauth2ProviderToken do fixtures :client_applications, :users, :oauth_tokens before(:each) do - @token = Oauth2Token.create :client_application => client_applications(:one), :user=>users(:aaron) + @token = Oauth2ProviderToken.create :client_application => client_applications(:one), :user=>users(:aaron) end it "should be valid" do diff --git a/lib/oauth/controllers/provider_controller.rb b/lib/oauth/controllers/provider_controller.rb index c61fcc3a..f4839bcd 100644 --- a/lib/oauth/controllers/provider_controller.rb +++ b/lib/oauth/controllers/provider_controller.rb @@ -152,7 +152,7 @@ def oauth2_token_password oauth2_error return end - @token = Oauth2Token.create :client_application=>@client_application, :user=>@user, :scope=>params[:scope] + @token = Oauth2ProviderToken.create :client_application=>@client_application, :user=>@user, :scope=>params[:scope] render :json=>@token end @@ -163,7 +163,7 @@ def authenticate_user(username,password) # autonomous authorization which creates a token for client_applications user def oauth2_token_client_credentials - @token = Oauth2Token.create :client_application=>@client_application, :user=>@client_application.user, :scope=>params[:scope] + @token = Oauth2ProviderToken.create :client_application=>@client_application, :user=>@client_application.user, :scope=>params[:scope] render :json=>@token end diff --git a/lib/oauth/provider/authorizer.rb b/lib/oauth/provider/authorizer.rb index 89951f32..aa64af71 100644 --- a/lib/oauth/provider/authorizer.rb +++ b/lib/oauth/provider/authorizer.rb @@ -23,7 +23,7 @@ def code end def token - @token ||= ::Oauth2Token.create! :client_application => app, + @token ||= ::Oauth2ProviderToken.create! :client_application => app, :user => @user, :scope => @params[:scope], :callback_url => @params[:redirect_uri] diff --git a/lib/oauth/rack/oauth_filter.rb b/lib/oauth/rack/oauth_filter.rb index 98eaa750..e0ec69c4 100644 --- a/lib/oauth/rack/oauth_filter.rb +++ b/lib/oauth/rack/oauth_filter.rb @@ -24,7 +24,7 @@ def call(env) env["oauth_plugin"] = true strategies = [] if token_string = oauth2_token(request) - if token = Oauth2Token.where('invalidated_at IS NULL and authorized_at IS NOT NULL and token = ?', token_string).first + if token = Oauth2ProviderToken.where('invalidated_at IS NULL and authorized_at IS NOT NULL and token = ?', token_string).first env["oauth.token"] = token env["oauth.version"] = 2 strategies << :oauth20_token diff --git a/spec/dummy_provider_models.rb b/spec/dummy_provider_models.rb index c5537d7c..756d6637 100644 --- a/spec/dummy_provider_models.rb +++ b/spec/dummy_provider_models.rb @@ -40,7 +40,7 @@ def secret end end -class Oauth2Token < OauthToken ; end +class Oauth2ProviderToken < OauthToken ; end class Oauth2Verifier < OauthToken ; end class AccessToken < OauthToken ; end class RequestToken < OauthToken ; end diff --git a/spec/oauth/provider/authorizer_spec.rb b/spec/oauth/provider/authorizer_spec.rb index f7b8f62b..44d5ea2f 100644 --- a/spec/oauth/provider/authorizer_spec.rb +++ b/spec/oauth/provider/authorizer_spec.rb @@ -109,7 +109,7 @@ end it "should allow" do - ::Oauth2Token.should_receive(:create!).with( :client_application=>@app, + ::Oauth2providerToken.should_receive(:create!).with( :client_application=>@app, :user=>@user, :callback_url=>'http://mysite.com/callback', :scope => 'a b').and_return(@token) @@ -125,7 +125,7 @@ end it "should include state" do - ::Oauth2Token.should_receive(:create!).with( :client_application=>@app, + ::Oauth2ProviderToken.should_receive(:create!).with( :client_application=>@app, :user=>@user, :callback_url=>'http://mysite.com/callback', :scope => 'a b').and_return(@token) @@ -142,7 +142,7 @@ end it "should allow query string in callback" do - ::Oauth2Token.should_receive(:create!).with( :client_application=>@app, + ::Oauth2ProviderToken.should_receive(:create!).with( :client_application=>@app, :user=>@user, :callback_url=>'http://mysite.com/callback?this=one', :scope => 'a b').and_return(@token)