2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-17 18:37:27 -05:00
|
|
|
class Admin::ApplicationsController < Admin::ApplicationController
|
2016-11-22 03:57:31 -05:00
|
|
|
include OauthApplications
|
|
|
|
|
2015-01-17 18:37:27 -05:00
|
|
|
before_action :set_application, only: [:show, :edit, :update, :destroy]
|
2016-12-20 09:15:46 -05:00
|
|
|
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)
|
2019-03-21 09:31:05 -04:00
|
|
|
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
|
2019-03-21 09:31:05 -04:00
|
|
|
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
|
2017-07-26 17:06:30 -04:00
|
|
|
params.require(:doorkeeper_application).permit(:name, :redirect_uri, :trusted, :scopes)
|
2015-01-17 18:37:27 -05:00
|
|
|
end
|
|
|
|
end
|