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

57 lines
1.4 KiB
Ruby
Raw Normal View History

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
@applications = Doorkeeper::Application.where("owner_id IS NULL")
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)
redirect_to admin_application_path(@application), notice: 'Application was successfully updated.'
else
render :edit
end
end
def destroy
@application.destroy
2017-09-10 17:25:29 +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
@application = Doorkeeper::Application.where("owner_id IS NULL").find(params[:id])
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