fix: get_user_by_username

This commit is contained in:
dettlaff 2024-12-11 12:22:52 +04:00
parent 0f422a6fc8
commit 6d6583ced6

View file

@ -159,23 +159,22 @@ def update_user(
def get_user_by_username(username: str) -> UserDataUser: def get_user_by_username(username: str) -> UserDataUser:
user = ACTIVE_USERS_PROVIDER.get_user_by_username( if isinstance(ACTIVE_USERS_PROVIDER, JsonUserRepository):
username=username return ACTIVE_USERS_PROVIDER.get_user_by_username(username=username)
)
if not isinstance(ACTIVE_USERS_PROVIDER, JsonUserRepository): if username == "root":
if username == "root": return UserDataUser(
return UserDataUser( username="root",
username="root", user_type=UserDataUserOrigin.ROOT,
user_type=UserDataUserOrigin.ROOT, ssh_keys=get_ssh_keys(username="root"),
ssh_keys=get_ssh_keys(username="root"), )
)
try: user = ACTIVE_USERS_PROVIDER.get_user_by_username(username=username)
if user:
user.ssh_keys = get_ssh_keys(username=user.username) try:
except UserNotFound: user.ssh_keys = get_ssh_keys(username=user.username)
pass except UserNotFound:
pass
return user return user