Class: Monban::UseCase::Account::Change::Password

Inherits:
Base
  • Object
show all
Defined in:
lib/monban/use_case/account/change/password.rb

Instance Method Summary collapse

Instance Method Details

#change(params) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/monban/use_case/account/change/password.rb', line 19

def change(params)
  Getto::Params.new.validate(params) do |v|
    v.hash(
      account_id: v.integer{|val| param_error!(account_id: val) },
      password:   v.combine([v.string, v.not_empty]), # DO NOT LOGGING PASSWORD!!
    )
  end or param_error!(params: "FILTERED")

  repository.transaction do
    unless repository.(account_id: params[:account_id])
      error.not_found! "account_id: #{params[:account_id]}"
    end

    self.password.change(
      account_id: params[:account_id],
      password:   params[:password],
    )
  end

  nil
end