Class: Monban::UseCase::Auth::Change::Password

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

Instance Method Summary collapse

Instance Method Details

#change(params) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/monban/use_case/auth/change/password.rb', line 22

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]){|val| param_error!(password: val) },
    )
  end or param_error!(params: params)

  repository.transaction do
    # disable current reset-password token
    #   when user change own password
    repository.delete_reset_password_token(account_id: params[:account_id])

    repository.update_password_hash(
      account_id:    params[:account_id],
      password_hash: password.create(password: params[:password]),
      now:           time.now,
    )
  end

  nil
end