Sha256: b6802c9c8f1798ea88b899d04b9ffeea72ccee69328038d8567e87536d2d3349

Contents?: true

Size: 1.81 KB

Versions: 3

Compression:

Stored size: 1.81 KB

Contents

module Doorkeeper
  class ApplicationsController < Doorkeeper::ApplicationController
    layout 'doorkeeper/admin'

    before_action :authenticate_admin!
    before_action :set_application, only: [:show, :edit, :update, :destroy]

    def index
      @applications = if Application.respond_to?(:ordered_by)
                        Application.ordered_by(:created_at)
                      else
                        ActiveSupport::Deprecation.warn <<-MSG.squish
                          Doorkeeper #{Doorkeeper.configuration.orm} extension must implement #ordered_by
                          method for it's models as it will be used by default in Doorkeeper 5.
                        MSG

                        Application.all
                      end
    end

    def show; end

    def new
      @application = Application.new
    end

    def create
      @application = Application.new(application_params)
      if @application.save
        flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
        redirect_to oauth_application_url(@application)
      else
        render :new
      end
    end

    def edit; end

    def update
      if @application.update_attributes(application_params)
        flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :update])
        redirect_to oauth_application_url(@application)
      else
        render :edit
      end
    end

    def destroy
      flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :destroy]) if @application.destroy
      redirect_to oauth_applications_url
    end

    private

    def set_application
      @application = Application.find(params[:id])
    end

    def application_params
      params.require(:doorkeeper_application).permit(:name, :redirect_uri, :scopes)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-4.3.2 app/controllers/doorkeeper/applications_controller.rb
doorkeeper-4.3.1 app/controllers/doorkeeper/applications_controller.rb
doorkeeper-4.3.0 app/controllers/doorkeeper/applications_controller.rb