[WIP] Added auth user service #70

This commit is contained in:
Sven Heidemann 2022-10-14 13:17:25 +02:00
parent 2457107c63
commit 126637306d
3 changed files with 105 additions and 4 deletions

View File

@ -10,7 +10,7 @@ from bot_api.model.update_auth_user_dto import UpdateAuthUserDTO
from bot_data.model.auth_user import AuthUser from bot_data.model.auth_user import AuthUser
class AuthABC(ABC): class AuthServiceABC(ABC):
@abstractmethod @abstractmethod
def __init__(self): pass def __init__(self): pass

View File

@ -1,18 +1,60 @@
import traceback import traceback
from typing import Optional
from cpl_core.console import Console from cpl_core.console import Console
from bot_api.abc.dto_abc import DtoABC from bot_api.abc.dto_abc import DtoABC
from bot_data.model.auth_role_enum import AuthRoleEnum
class AuthUserDTO(DtoABC): class AuthUserDTO(DtoABC):
def __init__(self): def __init__(
self,
id: int,
first_name: str,
last_name: str,
email: str,
password: str,
confirmation_id: Optional[str],
auth_role: AuthRoleEnum,
):
DtoABC.__init__(self) DtoABC.__init__(self)
self._id = id
self._first_name = first_name
self._last_name = last_name
self._email = email
self._password = password
self._is_confirmed = confirmation_id is None
self._auth_role = auth_role
"""
long Id { get; set; }
string FirstName { get; set; }
string LastName { get; set; }
string EMail { get; set; }
string Password { get; set; }
bool IsConfirmed { get; set; }
AuthRoles AuthRole { get; set; }
"""
def from_dict(self, values: dict): def from_dict(self, values: dict):
pass self._id = values['Id']
self._first_name = values['FirstName']
self._last_name = values['LastName']
self._email = values['EMail']
self._password = values['Password']
self._is_confirmed = values['IsConfirmed']
self._auth_role = values['AuthRole']
def to_dict(self) -> dict: def to_dict(self) -> dict:
return { return {
"Id": self._id,
"FirstName": self._first_name,
"LastName": self._last_name,
"EMail": self._email,
"Password": self._password,
"IsConfirmed": self._is_confirmed,
"AuthRole": self._auth_role,
} }

View File

@ -1,4 +1,63 @@
class AuthService: from cpl_query.extension import List
from bot_api.abc.auth_service_abc import AuthServiceABC
from bot_api.filter.auth_user_select_criteria import AuthUserSelectCriteria
from bot_api.model.auth_user_dto import AuthUserDTO
from bot_api.model.reset_password_dto import ResetPasswordDTO
from bot_api.model.token_dto import TokenDTO
from bot_api.model.update_auth_user_dto import UpdateAuthUserDTO
from bot_data.model.auth_user import AuthUser
class AuthService(AuthServiceABC):
def __init__(self): def __init__(self):
pass pass
async def get_all_auth_users_async(self) -> List[AuthUser]:
pass
async def get_filtered_auth_users_async(self, criteria: AuthUserSelectCriteria) -> List[AuthUser]:
pass
async def get_auth_user_by_email_async(self, email: str) -> AuthUser:
pass
async def find_auth_user_by_email_async(self, email: str) -> AuthUser:
pass
async def add_auth_user_async(self, user_dto: AuthUserDTO) -> AuthUser:
pass
async def confirm_email_async(self, id: str) -> AuthUser:
pass
async def login_async(self, user_dto: AuthUserDTO) -> AuthUser:
pass
async def forgot_password_async(self, email: str) -> AuthUser:
pass
async def confirm_forgot_password_async(self, id: str) -> AuthUser:
pass
async def reset_password_async(self, rp_dto: ResetPasswordDTO) -> AuthUser:
pass
async def update_user_async(self, update_user_dto: UpdateAuthUserDTO) -> AuthUser:
pass
async def update_user_as_admin_async(self, update_user_dto: UpdateAuthUserDTO) -> AuthUser:
pass
async def refresh_async(self, token_dto: TokenDTO) -> AuthUser:
pass
async def revoke_async(self, token_dto: TokenDTO) -> AuthUser:
pass
async def delete_auth_user_by_email_async(self, email: str) -> AuthUser:
pass
async def delete_auth_user_async(self, user_dto: AuthUserDTO) -> AuthUser:
pass