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_authorization_handlers

Methods inherited from ApplicationController

#user_not_authorized_path

Instance Method Details

#showObject



10
11
12
13
# File 'app/controllers/decidim/account_controller.rb', line 10

def show
  authorize! :show, current_user
  @account = form(AccountForm).from_model(current_user)
end

#updateObject



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

def update
  authorize! :update, current_user
  @account = form(AccountForm).from_params(params)

  UpdateAccount.call(current_user, @account) do
    on(:ok) do |, unconfirmed_email|
      flash.now[:notice] = if unconfirmed_email
                             t("account.update.success_with_email_confirmation", scope: "decidim")
                           else
                             t("account.update.success", scope: "decidim")
                           end

      (current_user)
    end

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

  render action: :show
end