applications_controller.rb 948 字节
Newer Older
V
Valery Sizov 已提交
1 2 3 4 5
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
  before_filter :authenticate_user!
  layout "profile"

  def index
D
Dmitriy Zaporozhets 已提交
6
    head :forbidden and return
V
Valery Sizov 已提交
7 8 9 10
  end

  def create
    @application = Doorkeeper::Application.new(application_params)
D
Dmitriy Zaporozhets 已提交
11

V
Valery Sizov 已提交
12 13
    @application.owner = current_user
    
V
Valery Sizov 已提交
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
D
Dmitriy Zaporozhets 已提交
23 24 25 26
    if @application.destroy
      flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :destroy])
    end

27
    redirect_to applications_profile_url
V
Valery Sizov 已提交
28
  end
D
Dmitriy Zaporozhets 已提交
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
D
Dmitriy Zaporozhets 已提交
39
end