From ff07c3433e247fd6c3e332c4240043554dbd4da5 Mon Sep 17 00:00:00 2001 From: Marcin-Ramotowski Date: Sun, 16 Mar 2025 15:44:49 +0000 Subject: [PATCH] Added more env variables --- api/app.py | 2 +- api/user_views.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/app.py b/api/app.py index 4a63dae..92da015 100644 --- a/api/app.py +++ b/api/app.py @@ -11,7 +11,7 @@ if __name__ == "__main__": app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('SQLALCHEMY_DATABASE_URI') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True - app.config['JWT_SECRET_KEY'] = 'changeme' + app.config['JWT_SECRET_KEY'] = os.getenv('JWT_SECRET_KEY', 'changeme') app.register_blueprint(user_bp) app.register_blueprint(task_bp) db.init_app(app) diff --git a/api/user_views.py b/api/user_views.py index 6e31225..4ffe357 100644 --- a/api/user_views.py +++ b/api/user_views.py @@ -129,9 +129,11 @@ def init_db(): """Create default admin account if database is empty""" with db.session.begin(): if not User.query.first(): # Check if user table is empty + admin_username = os.getenv("TODOLIST_ADMIN_USERNAME", "admin") + admin_email = os.getenv("TODOLIST_ADMIN_EMAIL", "admin@example.pl") admin_password = os.getenv("TODOLIST_ADMIN_PASSWORD", "admin") hashed_password = generate_password_hash(admin_password) - admin = User(username='admin', email='admin@example.pl', password=hashed_password, role='Administrator') + admin = User(username=admin_username, email=admin_email, password=hashed_password, role='Administrator') db.session.add(admin) db.session.commit()