Class: Decidim::UpdatePassword

Inherits:
Command
  • Object
show all
Defined in:
decidim-core/app/commands/decidim/update_password.rb

Overview

Decidim command updates user’s password

Instance Method Summary collapse

Constructor Details

#initialize(user, form) ⇒ UpdatePassword

Updates a user’s password.

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



10
11
12
13
# File 'decidim-core/app/commands/decidim/update_password.rb', line 10

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

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
# File 'decidim-core/app/commands/decidim/update_password.rb', line 15

def call
  return broadcast(:invalid) if form.invalid?

  user.password = form.password

  if user.save
    broadcast(:ok)
  else
    broadcast(:invalid)
  end
end