Sha256: f268972265be764ef428414950fb944448ed09236ec5ef390820f75ca1778872

Contents?: true

Size: 616 Bytes

Versions: 6

Compression:

Stored size: 616 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Decidim command updates user's password
  class UpdatePassword < Decidim::Command
    delegate :current_user, to: :form

    # Updates a user's password.
    #
    # form - The form with the data.
    def initialize(form)
      @form = form
    end

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

      current_user.password = form.password
      current_user.password_updated_at = Time.current

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

    private

    attr_reader :form
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/commands/decidim/update_password.rb
decidim-core-0.29.0 app/commands/decidim/update_password.rb
decidim-core-0.29.0.rc4 app/commands/decidim/update_password.rb
decidim-core-0.29.0.rc3 app/commands/decidim/update_password.rb
decidim-core-0.29.0.rc2 app/commands/decidim/update_password.rb
decidim-core-0.29.0.rc1 app/commands/decidim/update_password.rb