feat: set buyer as the authenticated user's username when adding a game
This commit is contained in:
parent
7bf9763a95
commit
b9dfa6adba
@ -22,11 +22,12 @@ def add_game():
|
|||||||
if not authenticate():
|
if not authenticate():
|
||||||
return jsonify({'message': 'Unauthorized access!'}), 401
|
return jsonify({'message': 'Unauthorized access!'}), 401
|
||||||
data = request.json
|
data = request.json
|
||||||
|
buyer_username = g.user.username # Get the username from the authenticated user
|
||||||
new_game = Game(
|
new_game = Game(
|
||||||
image=data['image'],
|
image=data['image'],
|
||||||
title=data['title'],
|
title=data['title'],
|
||||||
date=datetime.now().strftime('%Y-%m-%d'), # Set current date
|
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']
|
owned=data['owned']
|
||||||
)
|
)
|
||||||
db.session.add(new_game)
|
db.session.add(new_game)
|
||||||
|
Loading…
Reference in New Issue
Block a user