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

59 lines
1.4 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
def index
2018-10-17 20:43:35 -04:00
@applications = ApplicationsFinder.new.execute
2015-01-17 18:37:27 -05:00
end
def show
end
def new
@application = Doorkeeper::Application.new
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])
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: 302, 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
# Only allow a trusted parameter "white list" through.
def application_params
params.require(:doorkeeper_application).permit(:name, :redirect_uri, :trusted, :scopes)
2015-01-17 18:37:27 -05:00
end
end