From b9dfa6adba5e368086718f1f71224500f7e9555e Mon Sep 17 00:00:00 2001 From: "Manuel Weiser (aider)" Date: Mon, 2 Sep 2024 11:47:29 +0200 Subject: [PATCH] feat: set buyer as the authenticated user's username when adding a game --- game_collection/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/game_collection/app.py b/game_collection/app.py index b713adf..e612d40 100644 --- a/game_collection/app.py +++ b/game_collection/app.py @@ -22,11 +22,12 @@ def add_game(): if not authenticate(): return jsonify({'message': 'Unauthorized access!'}), 401 data = request.json + buyer_username = g.user.username # Get the username from the authenticated user new_game = Game( image=data['image'], title=data['title'], date=datetime.now().strftime('%Y-%m-%d'), # Set current date - buyer=data['buyer'], + buyer=buyer_username, # Set buyer as the authenticated user's username owned=data['owned'] ) db.session.add(new_game)