Class: Decidim::System::OAuthApplicationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/decidim/system/oauth_applications_controller.rb

Overview

Controller that allows managing OAuth applications at the admin panel.

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/decidim/system/oauth_applications_controller.rb', line 22

def create
  @form = form(OAuthApplicationForm).from_params(params)

  CreateOAuthApplication.call(@form) do
    on(:ok) do
      flash[:notice] = I18n.t("oauth_applications.create.success", scope: "decidim.system")
      redirect_to action: :index
    end

    on(:invalid) do
      flash.now[:alert] = I18n.t("oauth_applications.create.error", scope: "decidim.system")
      render :new
    end
  end
end

#destroyObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/decidim/system/oauth_applications_controller.rb', line 63

def destroy
  @oauth_application = collection.find(params[:id])

  DestroyOAuthApplication.call(@oauth_application, current_user) do
    on(:ok) do
      flash[:notice] = I18n.t("oauth_applications.destroy.success", scope: "decidim.system")
      redirect_to action: :index
    end

    on(:invalid) do
      flash.now[:error] = I18n.t("oauth_applications.destroy.error", scope: "decidim.system")
      redirect_to :back
    end
  end
end

#editObject



38
39
40
41
# File 'app/controllers/decidim/system/oauth_applications_controller.rb', line 38

def edit
  @oauth_application = collection.find(params[:id])
  @form = form(OAuthApplicationForm).from_model(@oauth_application)
end

#indexObject



10
11
12
# File 'app/controllers/decidim/system/oauth_applications_controller.rb', line 10

def index
  @oauth_applications = collection.page(params[:page]).per(15)
end

#newObject



18
19
20
# File 'app/controllers/decidim/system/oauth_applications_controller.rb', line 18

def new
  @form = form(OAuthApplicationForm).instance
end

#showObject



14
15
16
# File 'app/controllers/decidim/system/oauth_applications_controller.rb', line 14

def show
  @oauth_application = collection.find(params[:id])
end

#updateObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/decidim/system/oauth_applications_controller.rb', line 43

def update
  @oauth_application = collection.find(params[:id])
  @form = form(OAuthApplicationForm)
          .from_params(params.to_unsafe_h)
          .with_context(current_organization: @oauth_application.organization)

  UpdateOAuthApplication.call(@oauth_application, @form, current_user) do
    on(:ok) do |_application|
      flash[:notice] = I18n.t("oauth_applications.update.success", scope: "decidim.system")
      redirect_to action: :index
    end

    on(:invalid) do |application|
      @oauth_application = application
      flash.now[:error] = I18n.t("oauth_applications.update.error", scope: "decidim.system")
      render action: :edit
    end
  end
end