前后端更新
This commit is contained in:
1 parent
a0c8721fbb
commit
24da604727
33 files changed
+1951
-580
No files matched your search
@@ -0,0 +1,41 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add backend to path
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../backend')))
|
||||
|
||||
from app import create_app, db
|
||||
from app.models import User
|
||||
|
||||
app = create_app()
|
||||
|
||||
with app.app_context():
|
||||
print("Checking users...")
|
||||
|
||||
# Check test1
|
||||
user = db.session.query(User).filter_by(username='test1').first()
|
||||
if not user:
|
||||
print("User 'test1' not found. Creating...")
|
||||
user = User(username='test1', email='test1@example.com', role='user', real_name='Test User', employee_id='T001', phone_number='13800138001')
|
||||
user.set_password('test1')
|
||||
db.session.add(user)
|
||||
else:
|
||||
print("User 'test1' found. Resetting password to 'test1'...")
|
||||
user.set_password('test1')
|
||||
user.status = 'active' # Ensure active
|
||||
|
||||
# Check admin
|
||||
admin = db.session.query(User).filter_by(username='admin').first()
|
||||
if not admin:
|
||||
print("User 'admin' not found. Creating...")
|
||||
admin = User(username='admin', email='admin@example.com', role='admin', real_name='Administrator', employee_id='A001', phone_number='13800138000')
|
||||
admin.set_password('admin') # Default admin password
|
||||
db.session.add(admin)
|
||||
else:
|
||||
print("User 'admin' found. Resetting password to 'admin'...")
|
||||
admin.set_password('admin')
|
||||
admin.status = 'active'
|
||||
|
||||
db.session.commit()
|
||||
print("Done.")
|
||||
Reference in new issue
Block a user