2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-17 23:37:27 +00:00
|
|
|
class Admin::ApplicationsController < Admin::ApplicationController
|
2016-11-22 08:57:31 +00:00
|
|
|
include OauthApplications
|
|
|
|
|
2015-01-17 23:37:27 +00:00
|
|
|
before_action :set_application, only: [:show, :edit, :update, :destroy]
|
2016-12-20 14:15:46 +00:00
|
|
|
before_action :load_scopes, only: [:new, :create, :edit, :update]
|
2015-01-17 23:37:27 +00:00
|
|
|
|
|
|
|
def index
|
2018-10-18 00:43:35 +00:00
|
|
|
@applications = ApplicationsFinder.new.execute
|
2015-01-17 23:37:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@application = Doorkeeper::Application.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2017-11-02 13:33:56 +00:00
|
|
|
@application = Applications::CreateService.new(current_user, application_params).execute(request)
|
2015-01-18 00:17:34 +00:00
|
|
|
|
2017-10-24 06:38:06 +00:00
|
|
|
if @application.persisted?
|
|
|
|
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
|
|
|
|
|
|
|
|
redirect_to admin_application_url(@application)
|
2015-01-17 23:37:27 +00:00
|
|
|
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-06-06 22:45:16 +00:00
|
|
|
redirect_to admin_applications_url, status: 302, notice: 'Application was successfully destroyed.'
|
2015-01-17 23:37:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_application
|
2018-10-18 08:46:03 +00:00
|
|
|
@application = ApplicationsFinder.new(id: params[:id]).execute
|
2015-01-17 23:37:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Only allow a trusted parameter "white list" through.
|
|
|
|
def application_params
|
2017-07-26 21:06:30 +00:00
|
|
|
params.require(:doorkeeper_application).permit(:name, :redirect_uri, :trusted, :scopes)
|
2015-01-17 23:37:27 +00:00
|
|
|
end
|
|
|
|
end
|