Class: Decidim::UpdateAccount

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/decidim/update_account.rb

Overview

This command updates the user’s account.

Instance Method Summary collapse

Constructor Details

#initialize(user, form) ⇒ UpdateAccount

Updates a user’s account.

user - The user to be updated. form - The form with the data.



9
10
11
12
# File 'app/commands/decidim/update_account.rb', line 9

def initialize(user, form)
  @user = user
  @form = form
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/commands/decidim/update_account.rb', line 14

def call
  return broadcast(:invalid) unless @form.valid?

  update_personal_data
  update_avatar
  update_password
  @user.save!

  @form.remove_avatar = false
  broadcast(:ok, @user.unconfirmed_email.present?)
end