diff --git a/game_collection/app.py b/game_collection/app.py index 24f2664..b713adf 100644 --- a/game_collection/app.py +++ b/game_collection/app.py @@ -1,8 +1,8 @@ -from flask import Flask, request, jsonify +from flask import Flask, request, jsonify, g from flask_sqlalchemy import SQLAlchemy from database import init_db from models import db, Game -from user_management import user_bp +from user_management import user_bp, authenticate import os from datetime import datetime @@ -19,6 +19,8 @@ with app.app_context(): @app.route('/games', methods=['POST']) def add_game(): + if not authenticate(): + return jsonify({'message': 'Unauthorized access!'}), 401 data = request.json new_game = Game( image=data['image'], @@ -33,6 +35,8 @@ def add_game(): @app.route('/games', methods=['GET']) def get_games(): + if not authenticate(): + return jsonify({'message': 'Unauthorized access!'}), 401 games = Game.query.all() return jsonify([{ 'id': game.id,