Class: Blockspring::CLI::Command::Auth

Inherits:
Base
  • Object
show all
Defined in:
lib/blockspring/cli/command/auth.rb

Overview

authentication (login, logout)

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, namespace

Methods included from Helpers

#display, #error, error_with_failure, error_with_failure=, #format_with_bang, #home_directory, #longest, #output_with_bang, #running_on_a_mac?, #running_on_windows?

Constructor Details

This class inherits a constructor from Blockspring::CLI::Command::Base

Instance Method Details

#indexObject

auth

Authenticate, display current user



10
11
12
13
14
15
# File 'lib/blockspring/cli/command/auth.rb', line 10

def index
  user, _key = Blockspring::CLI::Auth.get_credentials
  if user
    puts "You are logged in as #{user}"
  end
end

#loginObject

auth:login

log in with your blockspring credentials

Example:

$ blockspring auth:login Enter your Blockspring credentials: Username or email: [email protected] Password (typing will be hidden): You are logged in as example



29
30
31
32
33
34
# File 'lib/blockspring/cli/command/auth.rb', line 29

def 
  user, _key = Blockspring::CLI::Auth.reauthorize
  if user
    puts "You are logged in as #{user}"
  end
end

#logoutObject

auth:logout

clear your blockspring credentials

Example:

$ blockspring auth:logout



44
45
46
47
# File 'lib/blockspring/cli/command/auth.rb', line 44

def logout
  Blockspring::CLI::Auth.delete_credentials
  puts "You have been logged out"
end