fix: change default params

This commit is contained in:
dettlaff 2024-12-10 04:52:13 +04:00
parent d210f5b37f
commit 9f5ee494a6
5 changed files with 39 additions and 39 deletions

View file

@ -63,10 +63,10 @@ def get_users(
def create_user(
username: str,
password: Optional[str] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
directmemberof: Optional[list[str]] = None,
memberof: Optional[list[str]] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
) -> None:
if is_username_forbidden(username):
@ -92,10 +92,10 @@ def create_user(
ACTIVE_USERS_PROVIDER.create_user(
username=username,
password=password,
displayname=displayname,
email=email,
directmemberof=directmemberof,
memberof=memberof,
displayname=displayname,
email=email,
)
@ -114,19 +114,19 @@ def delete_user(username: str) -> None:
def update_user(
username: str,
password: Optional[str] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
directmemberof: Optional[list[str]] = None,
memberof: Optional[list[str]] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
) -> None:
ACTIVE_USERS_PROVIDER.update_user(
username=username,
password=password,
displayname=displayname,
email=email,
directmemberof=directmemberof,
memberof=memberof,
displayname=displayname,
email=email,
)

View file

@ -53,12 +53,12 @@ def get_user_by_username(username: str) -> Optional[User]:
return User(
username=user.username,
ssh_keys=user.ssh_keys or [],
user_type=UserType(user.user_type.value) or None,
displayname=user.displayname or None,
email=user.email or None,
directmemberof=user.directmemberof or None,
memberof=user.memberof or None,
user_type=UserType(user.user_type.value),
ssh_keys=getattr(user, "ssh_keys", []),
directmemberof=getattr(user, "directmemberof", []),
memberof=getattr(user, "memberof", []),
displayname=getattr(user, "displayname", None),
email=getattr(user, "email", None),
)
@ -68,12 +68,12 @@ def get_users() -> list[User]:
return [
User(
username=user.username,
ssh_keys=user.ssh_keys or [],
user_type=UserType(user.user_type.value) or None,
displayname=user.displayname or None,
email=user.email or None,
directmemberof=user.directmemberof or None,
memberof=user.memberof or None,
user_type=UserType(user.user_type.value),
ssh_keys=getattr(user, "ssh_keys", []),
directmemberof=getattr(user, "directmemberof", []),
memberof=getattr(user, "memberof", []),
displayname=getattr(user, "displayname", None),
email=getattr(user, "email", None),
)
for user in users
]

View file

@ -88,10 +88,10 @@ class UsersMutations:
create_user_action(
username=user.username,
password=user.password,
displayname=user.displayname,
email=user.email,
directmemberof=user.directmemberof,
memberof=user.memberof,
displayname=user.displayname,
email=user.email,
)
except (
PasswordIsEmpty,
@ -165,10 +165,10 @@ class UsersMutations:
update_user_action(
username=user.username,
password=user.password,
displayname=user.displayname,
email=user.email,
directmemberof=user.directmemberof,
memberof=user.memberof,
displayname=user.displayname,
email=user.email,
)
except (PasswordIsEmpty, SelfPrivacyAppIsOutdate, KanidmDidNotReturnAdminPassword) as error:
return return_failed_mutation_return(

View file

@ -10,10 +10,10 @@ class AbstractUserRepository(ABC):
def create_user(
username: str,
password: Optional[str] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
directmemberof: Optional[list[str]] = None,
memberof: Optional[list[str]] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
) -> None:
"""
Creates a new user. In KanidmUserRepository "password" is a legacy field,
@ -41,10 +41,10 @@ class AbstractUserRepository(ABC):
def update_user(
username: str,
password: Optional[str] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
directmemberof: Optional[list[str]] = None,
memberof: Optional[list[str]] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
) -> None:
"""
Update user information.

View file

@ -221,13 +221,13 @@ class KanidmUserRepository(AbstractUserRepository):
continue
filled_user = UserDataUser(
username=user_attrs.get("name", [None]),
displayname=user_attrs.get("displayname", [None]),
email=user_attrs.get("mail", [None]),
ssh_keys=[], # actions layer will full in this field
username=user_attrs["name"],
user_type=user_type,
ssh_keys=[], # actions layer will full in this field
directmemberof=user_attrs.get("directmemberof", []),
memberof=user_attrs.get("memberof", []),
displayname=user_attrs.get("displayname", None),
email=user_attrs.get("mail", None),
)
users.append(filled_user)
@ -242,10 +242,10 @@ class KanidmUserRepository(AbstractUserRepository):
def update_user(
username: str,
password: Optional[str] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
directmemberof: Optional[list[str]] = None,
memberof: Optional[list[str]] = None,
displayname: Optional[str] = None,
email: Optional[str] = None,
) -> None:
"""
Update user information.
@ -288,15 +288,15 @@ class KanidmUserRepository(AbstractUserRepository):
attrs = user_data["attrs"]
return UserDataUser(
username=attrs.get("name", [None]),
displayname=attrs.get("displayname", [None]),
email=attrs.get("mail", [None]),
ssh_keys=[], # actions layer will full in this field
username=attrs["name"],
user_type=KanidmUserRepository._check_user_origin_by_memberof(
memberof=attrs.get("memberof", [])
),
ssh_keys=[], # actions layer will full in this field
directmemberof=attrs.get("directmemberof", []),
memberof=attrs.get("memberof", []),
displayname=attrs.get("displayname", None),
email=attrs.get("mail", None),
)
@staticmethod
@ -313,7 +313,7 @@ class KanidmUserRepository(AbstractUserRepository):
if not data:
raise KanidmReturnEmptyResponse
token = data.get("token", [None])
token = data.get("token", None)
if not token:
raise KanidmReturnEmptyResponse