adding current revision information
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from database import SessionLocal
|
||||
from models import User
|
||||
from passlib.context import CryptContext
|
||||
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
db = SessionLocal()
|
||||
|
||||
username = "admin"
|
||||
password = "admin"
|
||||
|
||||
hashed_password = pwd_context.hash(password)
|
||||
|
||||
admin_user = db.query(User).filter_by(username=username).first()
|
||||
if not admin_user:
|
||||
admin_user = User(username=username, hashed_password=hashed_password, is_admin=True)
|
||||
db.add(admin_user)
|
||||
db.commit()
|
||||
print("Admin user created successfully.")
|
||||
else:
|
||||
print("Admin user already exists.")
|
||||
|
||||
db.close()
|
||||
Reference in New Issue
Block a user