diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-03-11 23:38:25 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-13 16:51:09 -0400 |
commit | 8f21e2ae408a4ebd0e115846b9a639e7ce09a126 (patch) | |
tree | a5f6c45a79b30ab6c9d8afab117c3c534dd0cbfd /app/controllers/oauth | |
parent | 9f673aa498fed240db5c408b10d9107cec938aa3 (diff) | |
download | gitlab-ce-8f21e2ae408a4ebd0e115846b9a639e7ce09a126.tar.gz |
Let `oauth/applications#index` handle the `profiles#applications` routeapplication-settings
Previously we were doing all of kinds of code gymnastics and flash abuse
in order to work with a Doorkeeper controller but have it _appear_ at
the `/profile/applications` path. Fortunately we can just tell Rails to
use a different controller to handle that route, and we get the best of
both worlds.
Diffstat (limited to 'app/controllers/oauth')
-rw-r--r-- | app/controllers/oauth/applications_controller.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb index e20446b2cce..d1e4ac10f6c 100644 --- a/app/controllers/oauth/applications_controller.rb +++ b/app/controllers/oauth/applications_controller.rb @@ -8,11 +8,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController layout 'profile' def index - head :forbidden and return - end - - def new - redirect_to applications_profile_url + set_index_vars end def create @@ -24,18 +20,11 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) redirect_to oauth_application_url(@application) else - redirect_to applications_profile_url, flash: { application: @application } + set_index_vars + render :index end end - def destroy - if @application.destroy - flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :destroy]) - end - - redirect_to applications_profile_url - end - private def verify_user_oauth_applications_enabled @@ -44,6 +33,17 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController redirect_to applications_profile_url end + def set_index_vars + @applications = current_user.oauth_applications + @authorized_tokens = current_user.oauth_authorized_tokens + @authorized_anonymous_tokens = @authorized_tokens.reject(&:application) + @authorized_apps = @authorized_tokens.map(&:application).uniq.reject(&:nil?) + + # Don't overwrite a value possibly set by `create` + @application ||= Doorkeeper::Application.new + end + + # Override Doorkeeper to scope to the current user def set_application @application = current_user.oauth_applications.find(params[:id]) end |