Sha256: 9462db87fb98ffda02df51a325126f8fca6b5fe2e343592d0e9853bd0dc662b8

Contents?: true

Size: 671 Bytes

Versions: 7

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Decidim command updates user's password
  class UpdatePassword < Decidim::Command
    # Updates a user's password.
    #
    # user - The user to be updated.
    # form - The form with the data.
    def initialize(user, form)
      @user = user
      @form = form
    end

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

      user.password = form.password
      user.password_confirmation = form.password
      user.password_updated_at = Time.current

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

    private

    attr_reader :form, :user
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/commands/decidim/update_password.rb
decidim-core-0.27.8 app/commands/decidim/update_password.rb
decidim-core-0.27.7 app/commands/decidim/update_password.rb
decidim-core-0.27.6 app/commands/decidim/update_password.rb
decidim-core-0.27.5 app/commands/decidim/update_password.rb
decidim-core-0.27.4 app/commands/decidim/update_password.rb
decidim-core-0.27.3 app/commands/decidim/update_password.rb