Sha256: 79290590d8f2c7d882d7f4f951cc11a74cd862bd30f87b1622c6e78ce99ffca9
Contents?: true
Size: 1.37 KB
Versions: 7
Compression:
Stored size: 1.37 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] verify = input[:verify] if new_password != verify fail "Passwords don't match." end 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
7 entries across 7 versions & 1 rubygems