|
1 |
| -from datetime import datetime |
2 | 1 | import logging
|
3 | 2 | import sys
|
4 |
| -from safety.auth.models import Auth |
| 3 | +from datetime import datetime |
5 | 4 |
|
6 |
| -from safety.auth.utils import is_email_verified |
| 5 | +from safety.auth.models import Auth |
| 6 | +from safety.auth.utils import initialize, is_email_verified |
7 | 7 | from safety.console import main_console as console
|
8 | 8 | from safety.constants import MSG_FINISH_REGISTRATION_TPL, MSG_VERIFICATION_HINT
|
| 9 | +from safety.meta import get_version |
9 | 10 |
|
10 | 11 | try:
|
11 | 12 | from typing import Annotated
|
|
15 | 16 | from typing import Optional
|
16 | 17 |
|
17 | 18 | import click
|
18 |
| -from typer import Typer |
19 | 19 | import typer
|
| 20 | +from rich.padding import Padding |
| 21 | +from typer import Typer |
20 | 22 |
|
21 |
| -from safety.auth.main import get_auth_info, get_authorization_data, get_token, clean_session |
| 23 | +from safety.auth.main import ( |
| 24 | + clean_session, |
| 25 | + get_auth_info, |
| 26 | + get_authorization_data, |
| 27 | + get_token, |
| 28 | +) |
22 | 29 | from safety.auth.server import process_browser_callback
|
23 |
| -from ..cli_util import get_command_for, pass_safety_cli_obj, SafetyCLISubGroup |
24 |
| - |
25 |
| -from .constants import MSG_FAIL_LOGIN_AUTHED, MSG_FAIL_REGISTER_AUTHED, MSG_LOGOUT_DONE, MSG_LOGOUT_FAILED, MSG_NON_AUTHENTICATED |
26 |
| -from safety.scan.constants import CLI_AUTH_COMMAND_HELP, CLI_AUTH_HEADLESS_HELP, DEFAULT_EPILOG, CLI_AUTH_LOGIN_HELP, CLI_AUTH_LOGOUT_HELP, CLI_AUTH_STATUS_HELP |
27 |
| - |
28 |
| - |
29 |
| -from rich.padding import Padding |
| 30 | +from safety.scan.constants import ( |
| 31 | + CLI_AUTH_COMMAND_HELP, |
| 32 | + CLI_AUTH_HEADLESS_HELP, |
| 33 | + CLI_AUTH_LOGIN_HELP, |
| 34 | + CLI_AUTH_LOGOUT_HELP, |
| 35 | + CLI_AUTH_STATUS_HELP, |
| 36 | + DEFAULT_EPILOG, |
| 37 | +) |
| 38 | + |
| 39 | +from ..cli_util import SafetyCLISubGroup, get_command_for, pass_safety_cli_obj |
| 40 | +from .constants import ( |
| 41 | + MSG_FAIL_LOGIN_AUTHED, |
| 42 | + MSG_FAIL_REGISTER_AUTHED, |
| 43 | + MSG_LOGOUT_DONE, |
| 44 | + MSG_LOGOUT_FAILED, |
| 45 | + MSG_NON_AUTHENTICATED, |
| 46 | +) |
30 | 47 |
|
31 | 48 | LOG = logging.getLogger(__name__)
|
32 | 49 |
|
33 |
| -auth_app = Typer(rich_markup_mode="rich") |
| 50 | +auth_app = Typer(rich_markup_mode="rich", name="auth") |
34 | 51 |
|
35 | 52 |
|
36 | 53 |
|
@@ -183,6 +200,8 @@ def login(
|
183 | 200 |
|
184 | 201 | render_successful_login(ctx.obj.auth, organization=organization)
|
185 | 202 |
|
| 203 | + initialize(ctx, refresh=True) |
| 204 | + |
186 | 205 | console.print()
|
187 | 206 | if ctx.obj.auth.org or ctx.obj.auth.email_verified:
|
188 | 207 | console.print(
|
@@ -249,12 +268,13 @@ def status(ctx: typer.Context, ensure_auth: bool = False,
|
249 | 268 | """
|
250 | 269 | LOG.info('status started')
|
251 | 270 | current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
252 |
| - from safety.util import get_safety_version |
253 |
| - safety_version = get_safety_version() |
| 271 | + safety_version = get_version() |
254 | 272 | console.print(f"[{current_time}]: Safety {safety_version}")
|
255 | 273 |
|
256 | 274 | info = get_auth_info(ctx)
|
257 | 275 |
|
| 276 | + initialize(ctx, refresh=True) |
| 277 | + |
258 | 278 | if ensure_auth:
|
259 | 279 | console.print("running: safety auth status --ensure-auth")
|
260 | 280 | console.print()
|
|
0 commit comments