feat: create default admin user when initializing the database
This commit is contained in:
parent
7047f7c7e8
commit
78c13051d0
@ -1,6 +1,7 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
from werkzeug.security import generate_password_hash
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
db_path = os.path.join(current_app.instance_path, 'games.db')
|
db_path = os.path.join(current_app.instance_path, 'games.db')
|
||||||
@ -30,5 +31,12 @@ def init_db():
|
|||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
# Standardbenutzer erstellen
|
||||||
|
hashed_password = generate_password_hash("admin")
|
||||||
|
cursor.execute('''
|
||||||
|
INSERT OR IGNORE INTO users (username, password, role)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
''', ("admin", hashed_password, "admin"))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user