Sha256: 76e29f330bf343eef62c9c3d0221ce18c5b8fa04d993ce0d633509503dae12a2

Contents?: true

Size: 1.3 KB

Versions: 47

Compression:

Stored size: 1.3 KB

Contents

require "vmc/cli/user/base"

module VMC::User
  class Passwd < Base
    desc "Update a user's password"
    group :admin, :user, :hidden => true
    input :user, :desc => "User to update", :argument => :optional,
          :default => proc { client.current_user },
          :from_given => proc { |email|
            if v2? && client.current_user.email != email
              fail "You can only change your own password on V2."
            else
              client.user(email)
            end
          }
    input :password, :desc => "Current password"
    input :new_password, :desc => "New password"
    input :verify, :desc => "Repeat new password"
    def passwd
      user = input[:user]
      password = input[:password] if v2?
      new_password = input[:new_password]

      validate_password! new_password

      with_progress("Changing password") do
        if v2?
          user.change_password!(new_password, password)
        else
          user.password = new_password
          user.update!
        end
      end
    end

    private

    def ask_password
      ask("Current Password", :echo => "*", :forget => true)
    end

    def ask_new_password
      ask("New Password", :echo => "*", :forget => true)
    end

    def ask_verify
      ask("Verify Password", :echo => "*", :forget => true)
    end
  end
end

Version data entries

47 entries across 47 versions & 4 rubygems

Version Path
static-1.0.3 vendor/vmc-0.5.0/lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.11 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.10 lib/vmc/cli/user/passwd.rb
vmc-0.5.1.rc6 lib/vmc/cli/user/passwd.rb
static-1.0.1 vendor/vmc-0.5.0/lib/vmc/cli/user/passwd.rb
vmc-0.5.1.rc5 lib/vmc/cli/user/passwd.rb
vmc-0.5.1.rc4 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.9 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.8 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.7 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.6 lib/vmc/cli/user/passwd.rb
vmc-0.5.1.rc3 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.5 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.4 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.3 lib/vmc/cli/user/passwd.rb
vmc-0.5.1.rc2 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.2 lib/vmc/cli/user/passwd.rb
af-0.5.0.beta.1 lib/vmc/cli/user/passwd.rb
vmc-0.5.1.rc1 lib/vmc/cli/user/passwd.rb
vmc-0.5.0 lib/vmc/cli/user/passwd.rb