Class: Decidim::AccountController
Overview
The controller to handle the user’s account page.
Instance Method Summary
collapse
#available_authorization_handlers
Instance Method Details
#delete ⇒ Object
39
40
41
42
|
# File 'app/controllers/decidim/account_controller.rb', line 39
def delete
authorize! :delete, current_user
@form = form(DeleteAccountForm).from_model(current_user)
end
|
#destroy ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/decidim/account_controller.rb', line 44
def destroy
authorize! :delete, current_user
@form = form(DeleteAccountForm).from_params(params)
DestroyAccount.call(current_user, @form) do
on(:ok) do
sign_out(current_user)
flash[:notice] = t("account.destroy.success", scope: "decidim")
end
on(:invalid) do
flash[:alert] = t("account.destroy.error", scope: "decidim")
end
end
redirect_to decidim.root_path
end
|
#show ⇒ Object
11
12
13
14
|
# File 'app/controllers/decidim/account_controller.rb', line 11
def show
authorize! :show, current_user
@account = form(AccountForm).from_model(current_user)
end
|
#update ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/decidim/account_controller.rb', line 16
def update
authorize! :update, current_user
@account = form(AccountForm).from_params(account_params)
UpdateAccount.call(current_user, @account) do
on(:ok) do |email_is_unconfirmed|
flash[:notice] = if email_is_unconfirmed
t("account.update.success_with_email_confirmation", scope: "decidim")
else
t("account.update.success", scope: "decidim")
end
bypass_sign_in(current_user)
redirect_to account_path
end
on(:invalid) do
flash[:alert] = t("account.update.error", scope: "decidim")
render action: :show
end
end
end
|