From 214c7d63489301a7163a2137c1f928384a175857 Mon Sep 17 00:00:00 2001 From: Nicolas Rebagliati Date: Mon, 23 May 2022 10:35:14 -0300 Subject: [PATCH] check token on start in shell mode --- .pre-commit-config.yaml | 2 +- CHANGELOG/current/check_auth_on_start.md | 1 + faraday_cli/shell/shell.py | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG/current/check_auth_on_start.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa757b1..7f8e1cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: exclude: docs/mkdocs.yml - id: debug-statements - repo: https://github.com/psf/black - rev: 21.6b0 + rev: 22.3.0 hooks: - id: black language_version: python3 diff --git a/CHANGELOG/current/check_auth_on_start.md b/CHANGELOG/current/check_auth_on_start.md new file mode 100644 index 0000000..14a170a --- /dev/null +++ b/CHANGELOG/current/check_auth_on_start.md @@ -0,0 +1 @@ +Check if token is valid on start in shell mode diff --git a/faraday_cli/shell/shell.py b/faraday_cli/shell/shell.py index 28efd67..36f572c 100644 --- a/faraday_cli/shell/shell.py +++ b/faraday_cli/shell/shell.py @@ -105,10 +105,20 @@ def __init__(self, *args, **kwargs): ignore_ssl=active_config.ignore_ssl, token=active_config.token, ) + if not self.api_client.is_token_valid(): + intro.append( + style( + f"{self.emojis['cross']} Authentication invalid, run 'auth'", + fg=COLORS.RED, + ) + ) else: self.api_client = FaradayApi() intro.append( - style("Missing faraday server, run 'auth'", fg=COLORS.YELLOW) + style( + "Missing faraday authentication, run 'auth'", + fg=COLORS.YELLOW, + ) ) self.custom_plugins_path = active_config.custom_plugins_path self.ignore_info_severity = active_config.ignore_info_severity