Sha256: 069cb74cd14e8f960cfe49de5ae46da48c893d194dbc9a4288401bd768801871

Contents?: true

Size: 837 Bytes

Versions: 2

Compression:

Stored size: 837 Bytes

Contents

Execute.define_task do
  desc "set-admin-password", "Set the admin password"
  def set_admin_password
    token = get_token(false)
    new_pass,new_pass_confirm = '',''
    begin
      system "stty -echo"
      new_pass = ask "\nnew admin password: "
      new_pass_confirm = ask "\nconfirm new admin password: "
      system "stty echo"
    rescue NoMethodError, Interrupt
      system "stty echo"
      exit
    end #begin
    if new_pass == ''
      puts "\nNew password can't be empty."
    elsif new_pass == new_pass_confirm
      puts ""
      url = config[:syncserver]
      RestClient.put("#{url}/rc/v1/users/rhoadmin",
        { :attributes => { :new_password => new_pass }}.to_json, {:content_type => :json, 'X-RhoConnect-API-TOKEN' => token})
    else
      puts "\nNew password and confirmation must match."
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rhoconnect-4.0.0.beta.10 commands/rhoconnect/set_admin_password.rb
rhoconnect-4.0.0.beta.12 commands/rhoconnect/set_admin_password.rb