Permalink
Browse files

Merge pull request #101 from benoist/master

Return existing access_token for PasswordAccessTokenRequest
  • Loading branch information...
2 parents b3e14d0 + ce1129a commit 0bb36266d200e014dd43960d7ed5f7db9a4569a2 @felipeelias felipeelias committed Jul 15, 2012
Showing with 12 additions and 5 deletions.
  1. +2 −5 lib/doorkeeper/oauth/password_access_token_request.rb
  2. +10 −0 spec/requests/flows/password_spec.rb
@@ -51,7 +51,8 @@ def valid?
end
def access_token
- @access_token
+ return unless client.present? && resource_owner.present?
+ @access_token ||= Doorkeeper::AccessToken.matching_token_for client, resource_owner.id, scopes
end
def token_type
@@ -85,10 +86,6 @@ def revoke_and_create_access_token
create_access_token
end
- def revoke_base_token
- base_token.revoke
- end
-
def create_access_token
@access_token = Doorkeeper::AccessToken.create!({
:application_id => client.id,
@@ -32,6 +32,16 @@
should_have_json 'refresh_token', token.refresh_token
end
+
+ scenario 'should return the same token if it is still accessible' do
+ client_is_authorized(@client, @resource_owner)
+
+ post password_token_endpoint_url(:client => @client, :resource_owner => @resource_owner)
+
+ Doorkeeper::AccessToken.count.should be(1)
+
+ should_have_json 'access_token', Doorkeeper::AccessToken.first.token
+ end
end
context "with invalid user credentials" do

0 comments on commit 0bb3626

Please sign in to comment.