Skip to content

Commit 604e6a5

Browse files
committed
hid email
1 parent aaf9c4a commit 604e6a5

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,10 @@ async def add_user_in_group(
256256
msg = "Invalid method call, missing user id or user email"
257257
raise GroupsError(msg=msg)
258258

259-
# FIXME: check privacy
260259
if new_user_email:
261-
user = await _groups_db.get_user_from_email(app, email=new_user_email)
260+
user = await _groups_db.get_user_from_email(
261+
app, email=new_user_email, caller_user_id=user_id
262+
)
262263
new_user_id = user.id
263264

264265
if not new_user_id:

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

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,6 @@ async def _get_group_and_access_rights_or_raise(
113113
return row
114114

115115

116-
async def get_user_from_email(
117-
app: web.Application, connection: AsyncConnection | None = None, *, email: str
118-
) -> Row:
119-
"""
120-
Raises:
121-
UserNotFoundError
122-
123-
"""
124-
# FIXME: check privacy
125-
126-
async with pass_or_acquire_connection(get_asyncpg_engine(app), connection) as conn:
127-
result = await conn.stream(sa.select(users).where(users.c.email == email))
128-
user = await result.fetchone()
129-
if not user:
130-
raise UserNotFoundError(email=email)
131-
return user
132-
133-
134116
#
135117
# GROUPS
136118
#
@@ -356,6 +338,39 @@ async def delete_user_group(
356338
)
357339

358340

341+
#
342+
# USERS
343+
#
344+
345+
346+
async def get_user_from_email(
347+
app: web.Application,
348+
connection: AsyncConnection | None = None,
349+
*,
350+
caller_user_id: UserID,
351+
email: str,
352+
) -> Row:
353+
"""
354+
Raises:
355+
UserNotFoundError: if not found or privacy hides email
356+
357+
"""
358+
async with pass_or_acquire_connection(get_asyncpg_engine(app), connection) as conn:
359+
result = await conn.stream(
360+
sa.select(users.c.id).where(
361+
(users.c.email == email)
362+
& (
363+
users.c.privacy_hide_email.is_(False)
364+
| (users.c.id != caller_user_id)
365+
)
366+
)
367+
)
368+
user = await result.fetchone()
369+
if not user:
370+
raise UserNotFoundError(email=email)
371+
return user
372+
373+
359374
#
360375
# GROUP MEMBERS - CRUD
361376
#

0 commit comments

Comments
 (0)