From d5a746c9f654598c443795d9194a8c75f85ddcb7 Mon Sep 17 00:00:00 2001 From: jmcguffee Date: Thu, 5 Oct 2023 12:31:18 -0400 Subject: [PATCH] Updated dto and admin update api --- src/entities/models/dto.py | 4 +++- src/routers/admin.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/entities/models/dto.py b/src/entities/models/dto.py index ea3a6b2..d14f9fa 100644 --- a/src/entities/models/dto.py +++ b/src/entities/models/dto.py @@ -46,8 +46,10 @@ class UserProfile(BaseModel): last_name: str leis: Optional[Set[str]] + def to_keycloak_user(self): + return {"firstName": self.first_name, "lastName": self.last_name} + class Config: - alias_generator = to_lower_camel allow_population_by_field_name = True diff --git a/src/routers/admin.py b/src/routers/admin.py index 03428df..744809a 100644 --- a/src/routers/admin.py +++ b/src/routers/admin.py @@ -21,7 +21,7 @@ def get_me(request: Request): @router.put("/me/", status_code=HTTPStatus.ACCEPTED, dependencies=[Depends(check_domain)]) @requires("manage-account") def update_me(request: Request, user: UserProfile): - oauth2_admin.update_user(request.user.id, user.dict(by_alias=True, exclude={"leis"})) + oauth2_admin.update_user(request.user.id, user.to_keycloak_user()) if user.leis: oauth2_admin.associate_to_leis(request.user.id, user.leis)