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

59 lines
1.4 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
def index
2018-12-13 13:39:08 +05:30
@applications = ApplicationsFinder.new.execute
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-05-18 00:54:41 +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-05-18 00:54:41 +05:30
redirect_to admin_applications_url, status: 302, 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
2017-09-10 17:25:29 +05:30
params.require(:doorkeeper_application).permit(:name, :redirect_uri, :trusted, :scopes)
2015-04-26 12:48:37 +05:30
end
end