Module: Uffizzi::LoginHelper

Defined in:
lib/uffizzi/helpers/login_helper.rb

Class Method Summary collapse

Class Method Details

.prepare_request_params(username, password) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/uffizzi/helpers/login_helper.rb', line 8

def prepare_request_params(username, password)
  {
    user: {
      email: username,
      password: password,
    },
  }
end

.set_passwordObject



29
30
31
# File 'lib/uffizzi/helpers/login_helper.rb', line 29

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

.set_server(options) ⇒ Object



17
18
19
20
21
# File 'lib/uffizzi/helpers/login_helper.rb', line 17

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

.set_username(options) ⇒ Object



23
24
25
26
27
# File 'lib/uffizzi/helpers/login_helper.rb', line 23

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