Skip to content

Commit

Permalink
Updated dto and admin update api
Browse files Browse the repository at this point in the history
  • Loading branch information
guffee23 committed Oct 5, 2023
1 parent df3522f commit d5a746c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/entities/models/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/routers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d5a746c

Please sign in to comment.