From 00cecaab949214351a37eb82542957872a637402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Sun, 5 Jul 2020 09:16:17 -0400 Subject: [PATCH] Fix for #1024 --- bazarr/app.py | 4 ++-- bazarr/init.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bazarr/app.py b/bazarr/app.py index 31eb6be3e..0765841e4 100644 --- a/bazarr/app.py +++ b/bazarr/app.py @@ -5,7 +5,7 @@ from flask_socketio import SocketIO import os from get_args import args -from config import base_url +from config import settings, base_url socketio = SocketIO() @@ -19,7 +19,7 @@ def create_app(): app.wsgi_app = ReverseProxied(app.wsgi_app) app.route = prefix_route(app.route, base_url.rstrip('/')) - app.config["SECRET_KEY"] = 'test' + app.config["SECRET_KEY"] = settings.general.flask_secret_key app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True app.config['JSON_AS_ASCII'] = False diff --git a/bazarr/init.py b/bazarr/init.py index c9058a912..e2f37336a 100644 --- a/bazarr/init.py +++ b/bazarr/init.py @@ -71,6 +71,13 @@ if not settings.auth.apikey or settings.auth.apikey.startswith("b'"): with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: settings.write(handle) +# create random Flask secret_key if there's none in config.ini +if not settings.general.flask_secret_key: + from binascii import hexlify + settings.general.flask_secret_key = hexlify(os.urandom(16)).decode() + with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: + settings.write(handle) + # change default base_url to '' if settings.general.base_url == '/': settings.general.base_url = ''