Skip to content

Commit

Permalink
adding privacy
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Dec 4, 2024
1 parent 0f35ebe commit f4ef677
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
14 changes: 14 additions & 0 deletions services/web/server/src/simcore_service_webserver/users/_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pydantic import BaseModel


#
# REST models
#
class ProfilePrivacyGet(BaseModel):
hide_fullname: bool
hide_email: bool


class ProfilePrivacyUpdate(BaseModel):
hide_fullname: bool | None = None
hide_email: bool | None = None
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ async def get_user_profile(
sa.join(
users,
sa.join(
user_to_groups, groups, user_to_groups.c.gid == groups.c.gid
user_to_groups,
groups,
user_to_groups.c.gid == groups.c.gid,
),
users.c.id == user_to_groups.c.uid,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from simcore_postgres_database.models.users import UserRole

from ..utils import gravatar_hash
from ._models import ProfilePrivacyGet, ProfilePrivacyUpdate


#
Expand Down Expand Up @@ -66,6 +67,7 @@ class ProfileGet(BaseModel):
alias="expirationDate",
)

privacy: ProfilePrivacyGet = ProfilePrivacyGet(hide_fullname=True, hide_email=True)
preferences: AggregatedPreferences

model_config = ConfigDict(
Expand All @@ -74,6 +76,7 @@ class ProfileGet(BaseModel):
populate_by_name=True,
json_schema_extra={
"examples": [
# 1. with gravatar
{
"id": 1,
"login": "[email protected]",
Expand All @@ -82,6 +85,7 @@ class ProfileGet(BaseModel):
"gravatar_id": "205e460b479e2e5b48aec07710c08d50",
"preferences": {},
},
# 2. with expiration date
{
"id": 42,
"login": "[email protected]",
Expand Down Expand Up @@ -117,6 +121,8 @@ class ProfileUpdate(BaseModel):
first_name: FirstNameStr | None = None
last_name: LastNameStr | None = None

privacy: ProfilePrivacyUpdate | None = None

model_config = ConfigDict(
json_schema_extra={
"example": {
Expand Down

0 comments on commit f4ef677

Please sign in to comment.