Skip to content

Commit

Permalink
Store credentials if fractal db is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
thebalaa committed Jul 26, 2024
1 parent 8b2981e commit 489a08d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions fractal/cli/controllers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fractal.cli.utils import read_user_data, write_user_data
from fractal.matrix import MatrixClient, get_homeserver_for_matrix_id
from fractal.matrix.utils import parse_matrix_id, prompt_matrix_password
from fractal_database.utils import use_django
from fractal_database.utils import is_db_initialized
from nio import LoginError, WhoamiError


Expand All @@ -24,14 +24,12 @@ class AuthController:
TOKEN_FILE = "matrix.creds.yaml"

@cli_method
# @use_django move to store credential login to _login so we can still login without initing
def login(
self,
matrix_id: str,
password: Optional[str] = None,
homeserver_url: Optional[str] = None,
access_token: Optional[str] = None,
store_credential: bool = False,
**kwargs,
):
"""
Expand All @@ -42,7 +40,6 @@ def login(
password: Password for the Matrix ID.
homeserver_url: Homeserver to login to.
access_token: Access token to use for login.
store_credential: Create a MatrixCredential in the local database.
"""
if not access_token:
Expand Down Expand Up @@ -70,8 +67,7 @@ def login(
},
self.TOKEN_FILE,
)
if store_credential:
from fractal_database.models import Device
if is_db_initialized():
from fractal_database_matrix.models import (
MatrixCredentials,
MatrixHomeserver,
Expand Down

0 comments on commit 489a08d

Please sign in to comment.