Class: Decidim::AuthorizationsController

Inherits:
ApplicationController show all
Includes:
UserProfile
Defined in:
app/controllers/decidim/authorizations_controller.rb

Overview

This controller allows users to create and destroy their authorizations. It shouldn’t be necessary to expand it to add new authorization schemes.

Instance Method Summary collapse

Methods included from UserProfile

#available_authorization_handlers

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#createObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/decidim/authorizations_controller.rb', line 33

def create
  AuthorizeUser.call(handler) do
    on(:ok) do
      flash[:notice] = t("authorizations.create.success", scope: "decidim")
      redirect_to params[:redirect_url] || authorizations_path
    end

    on(:invalid) do
      flash[:alert] = t("authorizations.create.error", scope: "decidim")
      render action: :new
    end
  end
end

#first_loginObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/decidim/authorizations_controller.rb', line 23

def 
  if handlers.length == 1
    redirect_to(
      action: :new,
      handler: handlers.first.handler_name,
      redirect_url: 
    )
  end
end

#indexObject



19
20
21
# File 'app/controllers/decidim/authorizations_controller.rb', line 19

def index
  @authorizations = current_user.authorizations
end

#newObject



17
# File 'app/controllers/decidim/authorizations_controller.rb', line 17

def new; end