added user registration and login

This commit is contained in:
2025-01-20 15:42:10 +02:00
parent a6d0bbbd2b
commit 850360f553
16 changed files with 500 additions and 17 deletions

20
create_default_user.py Normal file
View File

@@ -0,0 +1,20 @@
from app import app, db, User, bcrypt
# Create the default user
username = 'admin'
password = '1234'
hashed_password = bcrypt.generate_password_hash(password).decode('utf-8')
with app.app_context():
# Delete the existing user if it exists
existing_user = User.query.filter_by(username=username).first()
if existing_user:
db.session.delete(existing_user)
db.session.commit()
# Add the new user to the database
default_user = User(username=username, password=hashed_password, role='admin')
db.session.add(default_user)
db.session.commit()
print(f"Default user '{username}' created with password '{password}'")