Skip to content

Commit 818588c

Browse files
committed
adds restricted access
1 parent cfe5d8d commit 818588c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

services/web/server/src/simcore_service_webserver/groups/_groups_repository.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sqlalchemy as sa
66
from aiohttp import web
77
from common_library.groups_enums import GroupType
8+
from common_library.users_enums import UserRole
89
from models_library.basic_types import IDStr
910
from models_library.groups import (
1011
AccessRightsDict,
@@ -499,11 +500,14 @@ async def list_users_in_group(
499500
.select_from(
500501
groups.join(
501502
user_to_groups, user_to_groups.c.gid == groups.c.gid, isouter=True
502-
)
503+
).join(users, users.c.id == user_to_groups.c.uid)
503504
)
504505
.where(
505506
((user_to_groups.c.uid == user_id) & (user_to_groups.c.gid == group_id))
506-
| (groups.c.type == GroupType.PRIMARY) # TODO: at least active users!
507+
| (
508+
(groups.c.type == GroupType.PRIMARY)
509+
& users.c.role.in_([r for r in UserRole if r > UserRole.GUEST])
510+
)
507511
)
508512
)
509513
group_row = result.first()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ async def get_user_or_raise(
169169
assert set(return_column_names).issubset(users.columns.keys()) # nosec
170170

171171
async with pass_or_acquire_connection(engine, connection) as conn:
172-
result = await conn.stream(
172+
result = await conn.execute(
173173
sa.select(*(users.columns[name] for name in return_column_names)).where(
174174
users.c.id == user_id
175175
)
176176
)
177-
row = await result.first()
177+
row = result.first()
178178
if row is None:
179179
raise UserNotFoundError(uid=user_id)
180180
user: dict[str, Any] = row._asdict()

0 commit comments

Comments
 (0)