Class: Decidim::AccountController

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

Overview

The controller to handle the user’s account page.

Instance Method Summary collapse

Methods included from UserProfile

#available_verification_workflows

Methods included from UserGroups

#enforce_user_groups_enabled

Methods included from UserBlockedChecker

#check_user_block_status, #check_user_not_blocked

Methods included from NeedsSnippets

#snippets

Methods included from HttpCachingDisabler

#disable_http_caching

Methods included from HasStoredPath

#skip_store_location?, #store_current_location

Methods included from RegistersPermissions

register_permissions

Methods included from NeedsOrganization

enhance_controller, extended, included

Instance Method Details

#deleteObject



36
37
38
39
# File 'app/controllers/decidim/account_controller.rb', line 36

def delete
  enforce_permission_to :delete, :user, current_user: current_user
  @form = form(DeleteAccountForm).from_model(current_user)
end

#destroyObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/decidim/account_controller.rb', line 41

def destroy
  enforce_permission_to :delete, :user, current_user: 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

#showObject



8
9
10
11
# File 'app/controllers/decidim/account_controller.rb', line 8

def show
  enforce_permission_to :show, :user, current_user: current_user
  @account = form(AccountForm).from_model(current_user)
end

#updateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/decidim/account_controller.rb', line 13

def update
  enforce_permission_to :update, :user, current_user: current_user
  @account = form(AccountForm).from_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

      (current_user)
      redirect_to 
    end

    on(:invalid) do
      flash[:alert] = t("account.update.error", scope: "decidim")
      render action: :show
    end
  end
end