Skip to content

Commit

Permalink
api: add update user
Browse files Browse the repository at this point in the history
  • Loading branch information
anarute committed Feb 12, 2024
1 parent 38d395d commit cd7afa5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/services/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ def get_user(self, username: str) -> AppUser:
def get_user_roles(self, user_id: int) -> List[UserRoles]:
roles = self.db.query(UserRoles).filter(UserRoles.user_id == user_id).all() or []
return roles

def update_user(self, username: str, **kwargs) -> AppUser:
user_in_db = self.db.query(User).filter(User.login == username).first() or None
for param, value in kwargs.items():
setattr(user_in_db, param, value)
self.db.commit()
self.db.refresh(user_in_db)
return UserProfile(user_in_db)

0 comments on commit cd7afa5

Please sign in to comment.