applications_controller.rb 944 Bytes
Newer Older
Valery Sizov's avatar
Valery Sizov committed
1
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
2
  before_action :authenticate_user!
Valery Sizov's avatar
Valery Sizov committed
3
4
5
  layout "profile"

  def index
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
6
    head :forbidden and return
Valery Sizov's avatar
Valery Sizov committed
7
8
9
10
  end

  def create
    @application = Doorkeeper::Application.new(application_params)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
11

Valery Sizov's avatar
Valery Sizov committed
12
    @application.owner = current_user
13

Valery Sizov's avatar
Valery Sizov committed
14
15
16
17
18
19
20
21
22
    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 destroy
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
23
24
25
26
    if @application.destroy
      flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :destroy])
    end

27
    redirect_to applications_profile_url
Valery Sizov's avatar
Valery Sizov committed
28
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
29
30
31
32
33
34
35
36
37
38

  private

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

  rescue_from ActiveRecord::RecordNotFound do |exception|
    render "errors/not_found", layout: "errors", status: 404
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
39
end