debian-mirror-gitlab/app/controllers/admin/applications_controller.rb

65 lines
1.6 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
class Admin::ApplicationsController < Admin::ApplicationController
2017-08-17 22:00:37 +05:30
include OauthApplications
2015-04-26 12:48:37 +05:30
before_action :set_application, only: [:show, :edit, :update, :destroy]
2017-08-17 22:00:37 +05:30
before_action :load_scopes, only: [:new, :create, :edit, :update]
2015-04-26 12:48:37 +05:30
2021-01-03 14:25:43 +05:30
feature_category :authentication_and_authorization
2015-04-26 12:48:37 +05:30
def index
2019-12-04 20:38:33 +05:30
applications = ApplicationsFinder.new.execute
@applications = Kaminari.paginate_array(applications).page(params[:page])
@application_counts = OauthAccessToken.distinct_resource_owner_counts(@applications)
2015-04-26 12:48:37 +05:30
end
def show
end
def new
@application = Doorkeeper::Application.new
end
def edit
end
def create
2018-03-17 18:26:18 +05:30
@application = Applications::CreateService.new(current_user, application_params).execute(request)
2015-04-26 12:48:37 +05:30
2018-03-17 18:26:18 +05:30
if @application.persisted?
2015-04-26 12:48:37 +05:30
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
2018-03-17 18:26:18 +05:30
2015-04-26 12:48:37 +05:30
redirect_to admin_application_url(@application)
else
render :new
end
end
def update
if @application.update(application_params)
2019-07-07 11:18:12 +05:30
redirect_to admin_application_path(@application), notice: _('Application was successfully updated.')
2015-04-26 12:48:37 +05:30
else
render :edit
end
end
def destroy
@application.destroy
2019-12-26 22:10:19 +05:30
redirect_to admin_applications_url, status: :found, notice: _('Application was successfully destroyed.')
2015-04-26 12:48:37 +05:30
end
private
def set_application
2018-12-13 13:39:08 +05:30
@application = ApplicationsFinder.new(id: params[:id]).execute
2015-04-26 12:48:37 +05:30
end
# Only allow a trusted parameter "white list" through.
def application_params
2020-03-09 13:42:32 +05:30
params
.require(:doorkeeper_application)
.permit(:name, :redirect_uri, :trusted, :scopes, :confidential)
2015-04-26 12:48:37 +05:30
end
end