gitlab-org--gitlab-foss/app/controllers/admin/applications_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.6 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2015-01-17 18:37:27 -05:00
class Admin::ApplicationsController < Admin::ApplicationController
include OauthApplications
2015-01-17 18:37:27 -05:00
before_action :set_application, only: [:show, :edit, :update, :destroy]
before_action :load_scopes, only: [:new, :create, :edit, :update]
2015-01-17 18:37:27 -05:00
feature_category :authentication_and_authorization
2015-01-17 18:37:27 -05:00
def index
applications = ApplicationsFinder.new.execute
@applications = Kaminari.paginate_array(applications).page(params[:page])
@application_counts = OauthAccessToken.distinct_resource_owner_counts(@applications)
2015-01-17 18:37:27 -05:00
end
def show
@created = get_created_session
2015-01-17 18:37:27 -05:00
end
def new
@application = Doorkeeper::Application.new
2015-01-17 18:37:27 -05:00
end
def edit
end
def create
2017-11-02 09:33:56 -04:00
@application = Applications::CreateService.new(current_user, application_params).execute(request)
2015-01-17 19:17:34 -05:00
2017-10-24 02:38:06 -04:00
if @application.persisted?
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
set_created_session
2017-10-24 02:38:06 -04:00
redirect_to admin_application_url(@application)
2015-01-17 18:37:27 -05:00
else
render :new
end
end
def update
if @application.update(application_params)
redirect_to admin_application_path(@application), notice: _('Application was successfully updated.')
2015-01-17 18:37:27 -05:00
else
render :edit
end
end
def destroy
@application.destroy
redirect_to admin_applications_url, status: :found, notice: _('Application was successfully destroyed.')
2015-01-17 18:37:27 -05:00
end
private
def set_application
2018-10-18 04:46:03 -04:00
@application = ApplicationsFinder.new(id: params[:id]).execute
2015-01-17 18:37:27 -05:00
end
def permitted_params
super << :trusted
end
2015-01-17 18:37:27 -05:00
def application_params
super.tap do |params|
params[:owner] = nil
end
2015-01-17 18:37:27 -05:00
end
end