Class: Beats::Auth
- Inherits:
-
Object
- Object
- Beats::Auth
- Defined in:
- lib/beats/auth.rb
Overview
Note:
Credentials are stored in a users home directiory in the file ~/.beats/credentials.yml.
Helper class for asking for and handling authentication credentials. The CLI interface uses this class to prompt the user for her credentials when she tries to access a protected resource.
Class Method Summary collapse
-
.access_token ⇒ String
Reads the users access token from her credentials file.
-
.login ⇒ Object
Prompt the user for her credentials.
-
.logout ⇒ Object
Wipe the current users credentials from the system.
Class Method Details
.access_token ⇒ String
Reads the users access token from her credentials file.
25 26 27 28 29 30 |
# File 'lib/beats/auth.rb', line 25 def access_token @credentials ||= read_credentials if @credentials @credentials['access_token'] end end |
.login ⇒ Object
Prompt the user for her credentials. Will display an interactive command line prompt. If the credentials are valid they will be cached in the ~/.beats/credentials.yml file (as an access token).
13 14 15 |
# File 'lib/beats/auth.rb', line 13 def login ask_for_credentials end |
.logout ⇒ Object
Wipe the current users credentials from the system.
18 19 20 |
# File 'lib/beats/auth.rb', line 18 def logout delete_credentials end |