Sha256: 26433d3903f1f918755e226010210d614c05defc0399da4785812f18a963d346

Contents?: true

Size: 1.06 KB

Versions: 25

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require 'uffizzi/helpers/config_helper'

module Uffizzi
  module LoginHelper
    class << self
      def prepare_request_params(username, password)
        {
          user: {
            email: username,
            password: password,
          },
        }
      end

      def set_server(options)
        config_server = ConfigFile.exists? ? Uffizzi::ConfigHelper.read_option_from_config(:server) : nil
        server_address = options[:server] || config_server || Uffizzi.configuration.default_server.to_s
        server_address.start_with?('http:', 'https:') ? server_address : "https://#{server_address}"
      end

      def set_username(options)
        config_username = ConfigFile.exists? ? Uffizzi::ConfigHelper.read_option_from_config(:username) : nil
        options_username = options[:email].present? ? options[:email] : nil
        options_username || config_username || Uffizzi.ui.ask('Username:')
      end

      def set_password
        ENV['UFFIZZI_PASSWORD'] || Uffizzi.ui.ask('Password:', echo: false)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
uffizzi-cli-2.4.11 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.10 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.9 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.8 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.7 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.6 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.5 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.4 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.3 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.2 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.1 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.4.0 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.3.4 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.3.3 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.3.2 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.3.1 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.3.0 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.2.2 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.2.1 lib/uffizzi/helpers/login_helper.rb
uffizzi-cli-2.2.0 lib/uffizzi/helpers/login_helper.rb