11import logging
2- from typing import NamedTuple
32
43import pycountry
54from aiohttp import web
87from models_library .users import UserBillingDetails , UserID
98from pydantic import TypeAdapter
109from simcore_postgres_database .models .users import UserStatus
10+ from simcore_service_webserver .products ._api import ProductName
1111
1212from ..db .plugin import get_asyncpg_engine
1313from . import _schemas , _users_repository
14- from ._users_repository import get_user_or_raise
15- from ._users_repository import list_user_permissions as db_list_of_permissions
16- from ._users_repository import update_user_status
14+ from ._models import UserCredentialsTuple
1715from .exceptions import AlreadyPreRegisteredError
1816from .schemas import Permission
1917
2018_logger = logging .getLogger (__name__ )
2119
2220
2321async def list_user_permissions (
24- app : web .Application , user_id : UserID , product_name : str
22+ app : web .Application ,
23+ * ,
24+ user_id : UserID ,
25+ product_name : ProductName ,
2526) -> list [Permission ]:
26- permissions : list [Permission ] = await db_list_of_permissions (
27+ permissions : list [Permission ] = await _users_repository . list_user_permissions (
2728 app , user_id = user_id , product_name = product_name
2829 )
2930 return permissions
3031
3132
32- class UserCredentialsTuple (NamedTuple ):
33- email : LowerCaseEmailStr
34- password_hash : str
35- display_name : str
36-
37-
3833async def get_user_credentials (
3934 app : web .Application , * , user_id : UserID
4035) -> UserCredentialsTuple :
41- row = await get_user_or_raise (
36+ row = await _users_repository . get_user_or_raise (
4237 get_asyncpg_engine (app ),
4338 user_id = user_id ,
4439 return_column_names = [
@@ -56,8 +51,8 @@ async def get_user_credentials(
5651 )
5752
5853
59- async def set_user_as_deleted (app : web .Application , user_id : UserID ) -> None :
60- await update_user_status (
54+ async def set_user_as_deleted (app : web .Application , * , user_id : UserID ) -> None :
55+ await _users_repository . update_user_status (
6156 get_asyncpg_engine (app ), user_id = user_id , new_status = UserStatus .DELETED
6257 )
6358
@@ -109,7 +104,9 @@ async def _list_products_or_none(user_id):
109104
110105
111106async def pre_register_user (
112- app : web .Application , profile : _schemas .PreUserProfile , creator_user_id : UserID
107+ app : web .Application ,
108+ profile : _schemas .PreUserProfile ,
109+ creator_user_id : UserID ,
113110) -> _schemas .UserProfile :
114111
115112 found = await search_users (app , email_glob = profile .email , include_products = False )
@@ -150,7 +147,7 @@ async def pre_register_user(
150147
151148
152149async def get_user_invoice_address (
153- app : web .Application , user_id : UserID
150+ app : web .Application , * , user_id : UserID
154151) -> UserInvoiceAddress :
155152 user_billing_details : UserBillingDetails = (
156153 await _users_repository .get_user_billing_details (
0 commit comments