Fix endless redirections when accessing user OAuth applications when they are disabled

Also hides the "Applications" nav button if OAuth applications are disabled by the admin.

Closes #14770
This commit is contained in:
Stan Hu 2016-06-07 23:15:45 -07:00
parent 703026c03e
commit 3b50d96b8a
4 changed files with 37 additions and 6 deletions

View File

@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.9.0 (unreleased) v 8.9.0 (unreleased)
- Bulk assign/unassign labels to issues. - Bulk assign/unassign labels to issues.
- Ability to prioritize labels !4009 / !3205 (Thijs Wouters) - Ability to prioritize labels !4009 / !3205 (Thijs Wouters)
- Fix endless redirections when accessing user OAuth applications when they are disabled
- Allow enabling wiki page events from Webhook management UI - Allow enabling wiki page events from Webhook management UI
- Bump rouge to 1.11.0 - Bump rouge to 1.11.0
- Make EmailsOnPushWorker use Sidekiq mailers queue - Make EmailsOnPushWorker use Sidekiq mailers queue

View File

@ -32,7 +32,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
def verify_user_oauth_applications_enabled def verify_user_oauth_applications_enabled
return if current_application_settings.user_oauth_applications? return if current_application_settings.user_oauth_applications?
redirect_to applications_profile_url redirect_to profile_path
end end
def set_index_vars def set_index_vars

View File

@ -10,11 +10,12 @@
= icon('gear fw') = icon('gear fw')
%span %span
Account Account
= nav_link(controller: 'oauth/applications') do - if current_application_settings.user_oauth_applications?
= link_to applications_profile_path, title: 'Applications' do = nav_link(controller: 'oauth/applications') do
= icon('cloud fw') = link_to applications_profile_path, title: 'Applications' do
%span = icon('cloud fw')
Applications %span
Applications
= nav_link(controller: :emails) do = nav_link(controller: :emails) do
= link_to profile_emails_path, title: 'Emails' do = link_to profile_emails_path, title: 'Emails' do
= icon('envelope-o fw') = icon('envelope-o fw')

View File

@ -0,0 +1,29 @@
require 'spec_helper'
describe Oauth::ApplicationsController do
let(:user) { create(:user) }
context 'project members' do
before do
sign_in(user)
end
describe 'GET #index' do
it 'shows list of applications' do
get :index
expect(response.status).to eq(200)
end
it 'redirects back to profile page if OAuth applications are disabled' do
settings = double(user_oauth_applications?: false)
allow_any_instance_of(Gitlab::CurrentSettings).to receive(:current_application_settings).and_return(settings)
get :index
expect(response.status).to eq(302)
expect(response).to redirect_to(profile_path)
end
end
end
end