From 4c053ff21a33fd60971616b698000eef1ace03a4 Mon Sep 17 00:00:00 2001 From: Brian Wallen Date: Wed, 16 Oct 2024 09:12:16 -0400 Subject: [PATCH] Get the flask-security token from /api/me. Fixes an issue in the UI that broke 2FA. --- opentakserver/blueprints/api.py | 4 ++-- opentakserver/models/user.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/opentakserver/blueprints/api.py b/opentakserver/blueprints/api.py index 692a8a1..e37068a 100644 --- a/opentakserver/blueprints/api.py +++ b/opentakserver/blueprints/api.py @@ -301,8 +301,8 @@ def certificate(): @api_blueprint.route('/api/me') @auth_required() def me(): - me = db.session.execute(db.session.query(User).where(User.id == current_user.id)).first()[0] - return jsonify(me.serialize()) + # me = db.session.execute(db.session.query(User).where(User.id == current_user.id)).first()[0] + return jsonify(current_user.to_json()) @api_blueprint.route('/api/cot', methods=['GET']) diff --git a/opentakserver/models/user.py b/opentakserver/models/user.py index dccb5d4..9b7000d 100644 --- a/opentakserver/models/user.py +++ b/opentakserver/models/user.py @@ -30,4 +30,6 @@ def serialize(self): } def to_json(self): - return self.serialize() + response = self.serialize() + response['token'] = self.get_auth_token() + return response