Class: Superbot::Cloud::CLI::LoginCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- Superbot::Cloud::CLI::LoginCommand
- Defined in:
- lib/superbot/cloud/cli/login_command.rb
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
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 web_login 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. == 'Invalid credentials' web_login end end |
#open_cloud_login_uri ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/superbot/cloud/cli/login_command.rb', line 30 def open_cloud_login_uri cloud_login_uri = 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(cloud_login_uri) puts "Your browser has been opened to visit:", cloud_login_uri puts end |
#web_login ⇒ Object
25 26 27 28 |
# File 'lib/superbot/cloud/cli/login_command.rb', line 25 def web_login open_cloud_login_uri Superbot::Web.run! end |