Class: Superbot::Cloud::CLI::LoginCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/superbot/cloud/cli/login_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/superbot/cloud/cli/login_command.rb', line 12

def execute
  return  if force? || Superbot::Cloud.credentials.nil?

  begin
    Superbot::Cloud::Api.request(:token)
    user_creds = Superbot::Cloud.credentials
    puts "Logged in as #{user_creds[:username]} (#{user_creds[:email]})"
  rescue SystemExit => e
    abort unless e.message == 'Invalid credentials'
    
  end
end

#open_cloud_login_uriObject



30
31
32
33
34
35
36
37
38
# File 'lib/superbot/cloud/cli/login_command.rb', line 30

def 
   = URI.parse(Superbot::Cloud::LOGIN_URI).tap do |uri|
    uri.query = URI.encode_www_form(redirect_uri: 'http://localhost:4567/login')
  end.to_s

  Launchy.open()
  puts "Your browser has been opened to visit:", 
  puts
end

#web_loginObject



25
26
27
28
# File 'lib/superbot/cloud/cli/login_command.rb', line 25

def 
  
  Superbot::Web.run!
end