mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-23 12:31:27 +00:00
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
|
from typing import Optional
|
||
|
|
||
|
from selfprivacy_api.repositories.users.abstract_user_repository import (
|
||
|
AbstractUserRepository,
|
||
|
UserDataUser,
|
||
|
)
|
||
|
|
||
|
from selfprivacy_api.utils.kanidm_manager import (
|
||
|
create_user,
|
||
|
delete_user,
|
||
|
get_user_by_username,
|
||
|
get_users,
|
||
|
update_user,
|
||
|
)
|
||
|
|
||
|
|
||
|
class KanidmUserRepository(AbstractUserRepository):
|
||
|
def get_users(
|
||
|
exclude_primary: bool = False,
|
||
|
exclude_root: bool = False,
|
||
|
) -> list[UserDataUser]:
|
||
|
return get_users(exclude_primary=exclude_primary, exclude_root=exclude_root)
|
||
|
|
||
|
def create_user(username: str, password: str):
|
||
|
"""Creates a new user"""
|
||
|
return create_user(username=username, password=password)
|
||
|
|
||
|
def delete_user(username: str) -> None:
|
||
|
"""Deletes an existing user"""
|
||
|
return delete_user(username=username)
|
||
|
|
||
|
def update_user(username: str, password: str) -> None:
|
||
|
"""Updates the password of an existing user"""
|
||
|
return update_user(username=username, password=password)
|
||
|
|
||
|
def get_user_by_username(username: str) -> Optional[UserDataUser]:
|
||
|
"""Retrieves user data (UserDataUser) by username"""
|
||
|
return get_user_by_username(username=username)
|