-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts
More file actions
40 lines (34 loc) · 1.32 KB
/
Copy pathscripts
File metadata and controls
40 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""
Quick script to create an admin user for testing the admin panel
"""
from app import app, db, User
from werkzeug.security import generate_password_hash
def create_admin_user():
with app.app_context():
# Check if admin user already exists
admin_user = User.query.filter_by(email='admin@carhub.com').first()
if admin_user:
print("✅ Admin user already exists!")
print(f"Email: {admin_user.email}")
print(f"Username: {admin_user.username}")
return
# Create admin user
admin_user = User(
username='admin',
email='admin@carhub.com',
password=generate_password_hash('admin123'), # Simple password for testing
is_verified=True
)
try:
db.session.add(admin_user)
db.session.commit()
print("✅ Admin user created successfully!")
print("Email: admin@carhub.com")
print("Password: admin123")
print("\nYou can now login and access the admin panel dropdown!")
except Exception as e:
print(f"❌ Error creating admin user: {e}")
db.session.rollback()
if __name__ == '__main__':
create_admin_user()