Class: Fizzy::Auth
- Inherits:
-
Object
- Object
- Fizzy::Auth
- Defined in:
- lib/fizzy/auth.rb
Constant Summary collapse
- CONFIG_DIR =
File.("~/.config/fizzy-cli")
- TOKEN_FILE =
File.join(CONFIG_DIR, "tokens.yml")
Class Method Summary collapse
Class Method Details
.normalize_slug(slug) ⇒ Object
18 19 20 |
# File 'lib/fizzy/auth.rb', line 18 def self.normalize_slug(slug) slug&.delete_prefix("/") end |
.resolve(account_slug = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/fizzy/auth.rb', line 8 def self.resolve(account_slug = nil) if ENV["FIZZY_TOKEN"] raise AuthError, "--account required with FIZZY_TOKEN" unless account_slug return { "access_token" => ENV["FIZZY_TOKEN"], "account_slug" => normalize_slug(account_slug) } end resolve_from_file(account_slug) end |
.token_data ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/fizzy/auth.rb', line 22 def self.token_data unless File.exist?(TOKEN_FILE) raise AuthError, "No tokens file at #{TOKEN_FILE}. Run: fizzy auth login --token TOKEN" end YAML.safe_load_file(TOKEN_FILE, permitted_classes: [Time]) end |