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
|
|
|
|
2020-10-05 17:08:47 -04:00
|
|
|
feature_category :authentication_and_authorization
|
|
|
|
|
2015-01-17 18:37:27 -05:00
|
|
|
def index
|
2019-09-09 20:05:55 -04:00
|
|
|
applications = ApplicationsFinder.new.execute
|
|
|
|
@applications = Kaminari.paginate_array(applications).page(params[:page])
|
|
|
|
@application_counts = OauthAccessToken.distinct_resource_owner_counts(@applications)
|
2015-01-17 18:37:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2021-11-04 11:10:58 -04:00
|
|
|
@created = get_created_session
|
2015-01-17 18:37:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2022-05-10 20:08:02 -04:00
|
|
|
@application = Doorkeeper::Application.new
|
2015-01-17 18:37:27 -05:00
|
|
|
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])
|
|
|
|
|
2021-11-04 11:10:58 -04:00
|
|
|
set_created_session
|
|
|
|
|
2017-10-24 02:38:06 -04:00
|
|
|
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-11-17 07:06:19 -05:00
|
|
|
redirect_to admin_applications_url, status: :found, 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
|
|
|
|
|
2021-09-17 11:11:44 -04:00
|
|
|
def permitted_params
|
|
|
|
super << :trusted
|
|
|
|
end
|
|
|
|
|
2015-01-17 18:37:27 -05:00
|
|
|
def application_params
|
2021-09-17 11:11:44 -04:00
|
|
|
super.tap do |params|
|
|
|
|
params[:owner] = nil
|
|
|
|
end
|
2015-01-17 18:37:27 -05:00
|
|
|
end
|
|
|
|
end
|