From 20ee9da1ec2cf22ac7fc68032f0eaf58920e8738 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Fri, 13 Feb 2026 11:02:53 +0100 Subject: [PATCH] Update flask_auth_routes.py --- AppImage/scripts/flask_auth_routes.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/AppImage/scripts/flask_auth_routes.py b/AppImage/scripts/flask_auth_routes.py index d28a299b..c7a8c7f3 100644 --- a/AppImage/scripts/flask_auth_routes.py +++ b/AppImage/scripts/flask_auth_routes.py @@ -178,9 +178,29 @@ def auth_login(): return jsonify({"success": False, "message": str(e)}), 500 +@auth_bp.route('/api/auth/setup', methods=['POST']) +def auth_setup(): + """Set up authentication with username and password (create user + enable auth)""" + try: + data = request.json + username = data.get('username') + password = data.get('password') + + success, message = auth_manager.setup_auth(username, password) + + if success: + # Generate a token so the user is logged in immediately + token = auth_manager.generate_token(username) + return jsonify({"success": True, "token": token, "message": message}) + else: + return jsonify({"success": False, "error": message}), 400 + except Exception as e: + return jsonify({"success": False, "error": str(e)}), 500 + + @auth_bp.route('/api/auth/enable', methods=['POST']) def auth_enable(): - """Enable authentication""" + """Enable authentication (must already be configured)""" try: success, message = auth_manager.enable_auth()