Defect #44654 ยป 0001-Fix-500-error-on-OAuth-API-requests-when-the-token-o.patch
| app/controllers/application_controller.rb | ||
|---|---|---|
|
# Oauth
|
||
|
if access_token.accessible?
|
||
|
user = User.active.find_by_id(access_token.resource_owner_id)
|
||
|
user.oauth_scope = access_token.scopes.all.map(&:to_sym)
|
||
|
user&.oauth_scope = access_token.scopes.all.map(&:to_sym)
|
||
|
else
|
||
|
doorkeeper_render_error
|
||
|
end
|
||
| test/integration/api_test/my_test.rb | ||
|---|---|---|
|
)
|
||
|
end
|
||
|
test "GET /my/account.json authenticated via OAuth with a locked user should respond with 401" do
|
||
|
application = Doorkeeper::Application.create!(
|
||
|
:name => 'Test App',
|
||
|
:redirect_uri => 'http://localhost/callback',
|
||
|
:scopes => 'view_issues'
|
||
|
)
|
||
|
token = Doorkeeper::AccessToken.create!(
|
||
|
:application_id => application.id,
|
||
|
:resource_owner_id => 2,
|
||
|
:scopes => 'view_issues',
|
||
|
:expires_in => 7200
|
||
|
)
|
||
|
User.find(2).update_column(:status, User::STATUS_LOCKED)
|
||
|
get '/my/account.json', :headers => {'Authorization' => "Bearer #{token.plaintext_token}"}
|
||
|
assert_response :unauthorized
|
||
|
end
|
||
|
test "GET /my/account.json authenticated via API key should disclose the api_key" do
|
||
|
key = User.find(2).api_key
|
||