Skip to content

Commit

Permalink
Avoid name clash
Browse files Browse the repository at this point in the history
  • Loading branch information
mremond committed Feb 2, 2014
1 parent 51c7dff commit d4ae78d
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion generators/oauth_provider/templates/oauth2_token.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Oauth2Token < AccessToken
class Oauth2ProviderToken < AccessToken
attr_accessor :state
def as_json(options={})
d = {:access_token=>token, :token_type => 'bearer'}
Expand Down
4 changes: 2 additions & 2 deletions generators/oauth_provider/templates/oauth2_token_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion generators/oauth_provider/templates/oauth2_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Oauth2Token < AccessToken
class Oauth2ProviderToken < AccessToken
attr_accessor :state
def as_json(options={})
d = {:access_token=>token, :token_type => 'bearer'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Oauth2Token < AccessToken
class Oauth2ProviderToken < AccessToken
attr_accessor :state
def as_json(options={})
d = {:access_token=>token, :token_type => 'bearer'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/rspec/templates/oauth2_token_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/oauth/controllers/provider_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/oauth/provider/authorizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/oauth/rack/oauth_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy_provider_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/oauth/provider/authorizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d4ae78d

Please sign in to comment.