Class: Nimbu::Command::Auth

Inherits:
Base
  • Object
show all
Defined in:
lib/nimbu/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, #nimbu

Methods included from Helpers

#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, disable_error_capture, #display, #display_header, #display_object, #display_row, #display_table, enable_error_capture, #error, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #output, #output_with_arrow, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #with_tty

Methods included from Helpers::System

#browser_launcher, #command?, #osx?, #tmp_dir, #which, #windows?

Constructor Details

This class inherits a constructor from Nimbu::Command::Base

Instance Method Details

#indexObject

auth

Authenticate, display token and current user



11
12
13
# File 'lib/nimbu/command/auth.rb', line 11

def index
  Nimbu::Command::Help.new.send(:help_for_command, current_command)
end

#loginObject

auth:login

log in with your nimbu credentials

Example:

$ nimbu auth:login

Please enter your Nimbu credentials:

Login: [email protected] (or your Nimbu username) Password (typing will be hidden)

Authentication successful.



30
31
32
33
# File 'lib/nimbu/command/auth.rb', line 30

def 
  Nimbu::Auth.
  display " => Authentication successful."
end

#logoutObject

auth:logout

clear local authentication credentials



41
42
43
44
# File 'lib/nimbu/command/auth.rb', line 41

def logout
  Nimbu::Auth.logout
  display "=> Local credentials cleared."
end

#tokenObject

auth:token

display your api token



63
64
65
# File 'lib/nimbu/command/auth.rb', line 63

def token
  display "=> Your personal API token is: #{Nimbu::Auth.token}"
end

#whoamiObject

auth:whoami

check the identity linked to your token



52
53
54
55
# File 'lib/nimbu/command/auth.rb', line 52

def whoami
  results = Nimbu::Auth.whoami
  display " => Logged in as: #{results[:name]} (#{results[:email]})"
end