UPDATE: Cleaned up code for some blueprints
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from blueprints.middleware import logged_in_user, register_error_handlers
|
|
||||||
# from flask_wtf.csrf import CSRFProtect, generate_csrf
|
|
||||||
|
|
||||||
|
from blueprints.middleware import logged_in_user, register_error_handlers
|
||||||
from blueprints.authentication import auth_bp
|
from blueprints.authentication import auth_bp
|
||||||
from blueprints.stripe import stripe_bp
|
from blueprints.stripe import stripe_bp
|
||||||
from blueprints.user import user_bp
|
from blueprints.user import user_bp
|
||||||
@@ -12,13 +11,12 @@ from blueprints.chat import chat_bp
|
|||||||
from blueprints.admin import admin_bp
|
from blueprints.admin import admin_bp
|
||||||
from blueprints.oauth import oauth_bp, init_oauth
|
from blueprints.oauth import oauth_bp, init_oauth
|
||||||
from blueprints.socket import socketio
|
from blueprints.socket import socketio
|
||||||
from celery import Celery
|
|
||||||
from celery_tasks import celery_init_app#
|
|
||||||
from blueprints.search_bar import search_bp
|
from blueprints.search_bar import search_bp
|
||||||
|
|
||||||
from os import getenv
|
from celery import Celery
|
||||||
|
from celery_tasks import celery_init_app
|
||||||
|
|
||||||
# csrf = CSRFProtect()
|
from os import getenv
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
"""
|
"""
|
||||||
@@ -49,20 +47,12 @@ def create_app():
|
|||||||
|
|
||||||
#! ↓↓↓ For development purposes only - Allow cross-origin requests for the frontend
|
#! ↓↓↓ For development purposes only - Allow cross-origin requests for the frontend
|
||||||
CORS(app, supports_credentials=True)
|
CORS(app, supports_credentials=True)
|
||||||
# csrf.init_app(app)
|
|
||||||
|
|
||||||
socketio.init_app(app)
|
socketio.init_app(app) # create socket connection
|
||||||
|
|
||||||
Session(app)
|
Session(app)
|
||||||
app.before_request(logged_in_user)
|
app.before_request(logged_in_user) # check user is logged in
|
||||||
init_oauth(app)
|
init_oauth(app)
|
||||||
|
register_error_handlers(app) # adds in error handlers
|
||||||
# adds in error handlers
|
|
||||||
register_error_handlers(app)
|
|
||||||
|
|
||||||
# @app.route('/csrf-token')
|
|
||||||
# def get_csrf_token():
|
|
||||||
# return jsonify({'csrf_token': generate_csrf()}), 200
|
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ admin_bp = Blueprint("admin", __name__)
|
|||||||
|
|
||||||
@admin_bp.route('/ban_user/<int:banned_user>')
|
@admin_bp.route('/ban_user/<int:banned_user>')
|
||||||
def admin_delete_user(banned_user):
|
def admin_delete_user(banned_user):
|
||||||
|
"""
|
||||||
|
Only to be used by a user who has admin privileges.
|
||||||
|
|
||||||
|
Contacts the database to ban a user for violation Terms of Service.
|
||||||
|
"""
|
||||||
|
|
||||||
# Sanitise the user input
|
# Sanitise the user input
|
||||||
banned_user = sanitize(banned_user)
|
banned_user = sanitize(banned_user)
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ from secrets import token_hex
|
|||||||
|
|
||||||
auth_bp = Blueprint("auth", __name__)
|
auth_bp = Blueprint("auth", __name__)
|
||||||
|
|
||||||
|
|
||||||
@auth_bp.route("/signup", methods=["POST"])
|
@auth_bp.route("/signup", methods=["POST"])
|
||||||
@cross_origin(supports_credentials=True)
|
@cross_origin(supports_credentials=True)
|
||||||
def signup():
|
def signup():
|
||||||
|
|||||||
Reference in New Issue
Block a user