Skip to content

Commit

Permalink
scopes field accepts Array
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Mar 11, 2019
1 parent 04389df commit 8aaff1a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ User-visible changes worth mentioning.

## master

- [#1214]: Scopes field accepts array.
- [#1209] Fix tokens validation for Token Introspection request.
- [#1202] Use correct HTTP status codes for error responses.

Expand Down
8 changes: 8 additions & 0 deletions lib/doorkeeper/models/concerns/scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ def scopes
OAuth::Scopes.from_string(scopes_string)
end

def scopes=(value)
if value.is_a? Array
super value.join(' ')
else
super value
end
end

def scopes_string
self[:scopes]
end
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/protected_resources/private_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
end

scenario 'access token with both allowed scopes' do
@token.update_attribute :scopes, 'write admin'
@token.update_attribute :scopes, %w[write admin]
with_access_token_header @token.token
visit '/full_protected_resources/1.json'
expect(page.body).to have_content('show')
Expand Down

0 comments on commit 8aaff1a

Please sign in to comment.