From 884ae0057472e3c112cde97434b02f1ab448e6be Mon Sep 17 00:00:00 2001 From: Tobias Kurze Date: Fri, 13 Oct 2023 16:09:34 +0200 Subject: [PATCH] readded fe --- backend/__init__.py | 4 ++-- backend/api/user_api.py | 13 +++++++------ backend/serve_frontend.py | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/__init__.py b/backend/__init__.py index 6107e9c..800c53e 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -167,7 +167,7 @@ except requests.exceptions.ConnectionError as err: # oidc_multi_auth = MultiAuth(oidc_auth, jwt_auth) <- can't work as OIDCAuthentication not implementing HTTPAuth -#from .serve_frontend import fe_bp +from .serve_frontend import fe_bp from .api import auth_api_bp, api_v1, api_bp CORS(app) @@ -176,7 +176,7 @@ CORS(api_bp) app.register_blueprint(auth_bp) app.register_blueprint(auth_api_bp) app.register_blueprint(api_bp) -#app.register_blueprint(fe_bp) +app.register_blueprint(fe_bp) diff --git a/backend/api/user_api.py b/backend/api/user_api.py index 682e83c..2546769 100644 --- a/backend/api/user_api.py +++ b/backend/api/user_api.py @@ -8,14 +8,14 @@ Login through API does not start a new session, but instead returns JWT. from datetime import datetime from pprint import pprint -from flask_jwt_extended import get_jwt_identity, jwt_required, current_user -from flask_restx import Resource, fields, inputs, abort +from flask_jwt_extended import get_jwt_identity, jwt_required, current_user, verify_jwt_in_request +from flask_restx import Resource, inputs, abort from backend import db, app, jwt_auth from backend.api import api_user from backend.api.models import user_model, recorder_model, generic_id_parser -from backend.models import Recorder -from backend.models.user_model import User, Group +from backend.models.recorder_model import Recorder +from backend.models.user_model import User user_update_parser = api_user.parser() @@ -27,10 +27,11 @@ user_update_parser.add_argument('last_name', type=str, required=False, store_mis @api_user.route('/profile') class Profile(Resource): - @jwt_required + @jwt_required() @api_user.marshal_with(user_model) def get(self): """Get infos about logged in user.""" + print("hey!") current_user_id = get_jwt_identity() app.logger.info(current_user_id) return User.get_by_identifier(current_user_id) @@ -102,7 +103,7 @@ class UserList(Resource): return User.get_all() @jwt_required - @api_user.doc('create_group') + @api_user.doc('create_user') @api_user.expect(user_model) @api_user.marshal_with(user_model, code=201) def post(self): diff --git a/backend/serve_frontend.py b/backend/serve_frontend.py index 59e1b25..797ae49 100644 --- a/backend/serve_frontend.py +++ b/backend/serve_frontend.py @@ -16,8 +16,8 @@ if not os.path.exists(fe_path) or not os.path.exists(os.path.join(fe_path, "inde app.logger.critical( "Frontend path and/or index.html does not exist! Please build frontend before continuing! " "You might want to go to ../frontend and continue from there.") - print("FATAL: Frontend path wrong or index.html missing -> EXITING!") - exit() + print("ERROR: Frontend path wrong or index.html missing -> NO WEB-UI AVAILABLE!") + #exit() fe_bp = Blueprint('frontend', __name__, url_prefix='/', template_folder=os.path.join(fe_path, ""))