Added more env variables
This commit is contained in:
parent
b2dc4856cb
commit
ff07c3433e
@ -11,7 +11,7 @@ if __name__ == "__main__":
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('SQLALCHEMY_DATABASE_URI')
|
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('SQLALCHEMY_DATABASE_URI')
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
|
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(user_bp)
|
||||||
app.register_blueprint(task_bp)
|
app.register_blueprint(task_bp)
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
@ -129,9 +129,11 @@ def init_db():
|
|||||||
"""Create default admin account if database is empty"""
|
"""Create default admin account if database is empty"""
|
||||||
with db.session.begin():
|
with db.session.begin():
|
||||||
if not User.query.first(): # Check if user table is empty
|
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")
|
admin_password = os.getenv("TODOLIST_ADMIN_PASSWORD", "admin")
|
||||||
hashed_password = generate_password_hash(admin_password)
|
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.add(admin)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user