Files

30 lines
1.1 KiB
Python

from app import create_app, db
from app.models import User
app = create_app()
with app.app_context():
# Check for admin user
admin = User.query.filter_by(username='admin').first()
if admin:
print(f"Found admin user. Current role: {admin.role}")
if admin.role != 'admin':
admin.role = 'admin'
print("Updated admin user role to 'admin'")
# Always update password to ensure it's set correctly
admin.set_password('Hxit@54321')
db.session.commit()
print("Updated admin user password to 'Hxit@54321'")
else:
print("Admin user not found. Creating...")
admin = User(username='admin', email='admin@example.com', role='admin')
admin.set_password('Hxit@54321')
db.session.add(admin)
db.session.commit()
print("Created admin user with role 'admin' and password 'Hxit@54321'")
# Also check if there are other users that should be admin but aren't
users = User.query.all()
for u in users:
print(f"User: {u.username}, Role: {u.role}")