Sha256: 470786fdc2ad2807a440b383102dc7e8d33ab8e3404c80687e0575acd5cad2b1

Contents?: true

Size: 576 Bytes

Versions: 5

Compression:

Stored size: 576 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

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

    private

    attr_reader :form, :user
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.27.2 app/commands/decidim/update_password.rb
decidim-core-0.27.1 app/commands/decidim/update_password.rb
decidim-core-0.27.0 app/commands/decidim/update_password.rb
decidim-core-0.27.0.rc2 app/commands/decidim/update_password.rb
decidim-core-0.27.0.rc1 app/commands/decidim/update_password.rb