Skip to content

Commit

Permalink
refactor: prevent email and username from being changed, comments added
Browse files Browse the repository at this point in the history
  • Loading branch information
slugb0t committed Oct 10, 2023
1 parent 563baf8 commit 1f00d45
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apis/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@

@api.route("/user/profile")
class UserDetailsEndpoint(Resource):
@api.doc("list_study")
@api.doc(description="Returns user details gathered from the user and user_details tables")
@api.response(200, "Success", study_model)
@api.response(400, "Validation Error")
def get(self):
"""Returns user details"""
user = User.query.get(g.user.id)
user_details = user.user_details
user_information = user.to_dict()
# combine user and user_details to return a single object
user_information.update(user_details.to_dict())
return user_information

Expand All @@ -43,8 +44,12 @@ def put(self):
if data is None:
return {"message": "No data provided"}, 400
user = User.query.get(g.user.id)
user.update(data)
# user.update(data) # don't update the username and email_address for now
user_details = user.user_details
user_details.update(data)
db.session.commit()
return user_details.to_dict()

# combine user and user_details to return a single object
user_information = user.to_dict()
user_information.update(user_details.to_dict())
return user_information

0 comments on commit 1f00d45

Please sign in to comment.