Sha256: 67c9dc9ddd38611884f06f87b5b6a2ddfdc9acac65b23c6bd6b88d1b9dd15b7c

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

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

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

    def index
      @applications = Application.all
    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 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
      if params.respond_to?(:permit)
        params.require(:doorkeeper_application).permit(:name, :redirect_uri, :scopes)
      else
        params[:doorkeeper_application].slice(:name, :redirect_uri, :scopes) rescue nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
doorkeeper-3.1.0 app/controllers/doorkeeper/applications_controller.rb
doorkeeper-3.0.1 app/controllers/doorkeeper/applications_controller.rb
doorkeeper-3.0.0 app/controllers/doorkeeper/applications_controller.rb
doorkeeper-3.0.0.rc2 app/controllers/doorkeeper/applications_controller.rb