Class: Duse::CLI::AccountPasswordChange

Inherits:
ApiCommand show all
Includes:
PasswordHelper
Defined in:
lib/duse/cli/account_password_change.rb

Instance Attribute Summary

Attributes inherited from Command

#arguments, #force_interactive, #input, #output

Instance Method Summary collapse

Methods included from PasswordHelper

#ask_for_current_password, #ask_for_password

Methods inherited from ApiCommand

#execute, #setup

Methods inherited from Command

abstract, abstract?, #check_arity, #color, #command_name, command_name, #config, description, #error, #execute, #format, #full_command, full_command, has_subcommands?, has_super_command?, #help, #help_subcommands, #initialize, #interactive?, #parse, #say, #setup, skip, subcommand, subcommands, #success, super_command, super_command=, #terminal, #usage, #usage_for, #warn, #write_to, #wrong_args

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

This class inherits a constructor from Duse::CLI::Command

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/duse/cli/account_password_change.rb', line 13

def run
  if self.token
    Duse.session.patch('/users/password', {
      token: self.token,
      password: ask_for_password
    })
  else
    user = Duse::User.current
    Duse::User.update(user.id, {
      password: ask_for_password,
      current_password: ask_for_current_password
    })
  end
  success 'Successfully updated your password!'
end