Class: Decidim::AuthorizationsController
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
#available_authorization_handlers
#user_not_authorized_path
Instance Method Details
#create ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 25
def create
AuthorizeUser.call(handler) do
on(:ok) do
flash[:notice] = t("authorizations.create.success", scope: "decidim")
redirect_to account_path
end
on(:invalid) do
flash[:alert] = t("authorizations.create.error", scope: "decidim")
render action: :new
end
end
end
|
#destroy ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 39
def destroy
@authorization = current_user.authorizations.find(params[:id])
authorize! :destroy, @authorization
@authorization.destroy
flash[:notice] = t("authorizations.destroy.success", scope: "decidim")
redirect_to account_path
end
|
#first_login ⇒ Object
21
22
23
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 21
def first_login
redirect_to(action: :new, handler: handlers.first.handler_name) if handlers.length == 1
end
|
#handler ⇒ Object
48
49
50
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 48
def handler
@handler ||= AuthorizationHandler.handler_for(handler_name, handler_params)
end
|
#index ⇒ Object
17
18
19
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 17
def index
@authorizations = current_user.authorizations
end
|
#new ⇒ Object
15
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 15
def new; end
|