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
#user_not_authorized_path
Instance Method Details
#create ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 20
def create
authorize! current_user, Authorization
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
36
37
38
39
40
41
42
43
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 36
def destroy
@authorization = current_user.authorizations.find(params[:id])
authorize! current_user, @authorization
@authorization.destroy
flash[:notice] = t("authorizations.destroy.success", scope: "decidim")
redirect_to account_path
end
|
#handler ⇒ Object
45
46
47
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 45
def handler
@handler ||= AuthorizationHandler.handler_for(handler_name, handler_params)
end
|
#handlers ⇒ Object
49
50
51
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 49
def handlers
@handlers ||= Decidim.authorization_handlers
end
|
#index ⇒ Object
16
17
18
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 16
def index
authorize! current_user, Authorization
end
|
#new ⇒ Object
12
13
14
|
# File 'app/controllers/decidim/authorizations_controller.rb', line 12
def new
authorize! current_user, Authorization
end
|