Skip to content

Commit 6ef1990

Browse files
committed
minor
1 parent 4be6d14 commit 6ef1990

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

services/web/server/src/simcore_service_webserver/users/_models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Annotated, Any, Self
22

3+
from models_library.emails import LowerCaseEmailStr
34
from pydantic import BaseModel, ConfigDict, Field
45

56
#
@@ -46,3 +47,9 @@ def from_api(cls, profile_update) -> Self:
4647

4748
def to_db(self) -> dict[str, Any]:
4849
return self.model_dump(exclude_unset=True, by_alias=False)
50+
51+
52+
class UserCredentialsTuple(NamedTuple):
53+
email: LowerCaseEmailStr
54+
password_hash: str
55+
display_name: str

services/web/server/src/simcore_service_webserver/users/_notifications_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def mark_notification_as_read(request: web.Request) -> web.Response:
126126
async def list_user_permissions(request: web.Request) -> web.Response:
127127
req_ctx = UsersRequestContext.model_validate(request)
128128
list_permissions: list[Permission] = await _users_service.list_user_permissions(
129-
request.app, req_ctx.user_id, req_ctx.product_name
129+
request.app, user_id=req_ctx.user_id, product_name=req_ctx.product_name
130130
)
131131
return envelope_json_response(
132132
[

services/web/server/src/simcore_service_webserver/users/_users_service.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
from typing import NamedTuple
32

43
import pycountry
54
from aiohttp import web
@@ -8,37 +7,33 @@
87
from models_library.users import UserBillingDetails, UserID
98
from pydantic import TypeAdapter
109
from simcore_postgres_database.models.users import UserStatus
10+
from simcore_service_webserver.products._api import ProductName
1111

1212
from ..db.plugin import get_asyncpg_engine
1313
from . 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
1715
from .exceptions import AlreadyPreRegisteredError
1816
from .schemas import Permission
1917

2018
_logger = logging.getLogger(__name__)
2119

2220

2321
async 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-
3833
async 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

111106
async 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

152149
async 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

Comments
 (0)