Class: Doorkeeper::ApplicationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/doorkeeper/applications_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/doorkeeper/applications_controller.rb', line 30

def create
  @application = Doorkeeper.config.application_model.new(application_params)

  if @application.save
    flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications create])
    flash[:application_secret] = @application.plaintext_secret

    respond_to do |format|
      format.html { redirect_to oauth_application_url(@application) }
      format.json { render json: @application, as_owner: true }
    end
  else
    respond_to do |format|
      format.html { render :new }
      format.json do
        errors = @application.errors.full_messages

        render json: { errors: errors }, status: :unprocessable_entity
      end
    end
  end
end

#destroyObject



75
76
77
78
79
80
81
82
# File 'app/controllers/doorkeeper/applications_controller.rb', line 75

def destroy
  flash[:notice] = I18n.t(:notice, scope: i18n_scope(:destroy)) if @application.destroy

  respond_to do |format|
    format.html { redirect_to oauth_applications_url }
    format.json { head :no_content }
  end
end

#editObject



53
# File 'app/controllers/doorkeeper/applications_controller.rb', line 53

def edit; end

#indexObject



10
11
12
13
14
15
16
17
# File 'app/controllers/doorkeeper/applications_controller.rb', line 10

def index
  @applications = Doorkeeper.config.application_model.ordered_by(:created_at)

  respond_to do |format|
    format.html
    format.json { head :no_content }
  end
end

#newObject



26
27
28
# File 'app/controllers/doorkeeper/applications_controller.rb', line 26

def new
  @application = Doorkeeper.config.application_model.new
end

#showObject



19
20
21
22
23
24
# File 'app/controllers/doorkeeper/applications_controller.rb', line 19

def show
  respond_to do |format|
    format.html
    format.json { render json: @application, as_owner: true }
  end
end

#updateObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/doorkeeper/applications_controller.rb', line 55

def update
  if @application.update(application_params)
    flash[:notice] = I18n.t(:notice, scope: i18n_scope(:update))

    respond_to do |format|
      format.html { redirect_to oauth_application_url(@application) }
      format.json { render json: @application, as_owner: true }
    end
  else
    respond_to do |format|
      format.html { render :edit }
      format.json do
        errors = @application.errors.full_messages

        render json: { errors: errors }, status: :unprocessable_entity
      end
    end
  end
end