Spaces:
Sleeping
Sleeping
File size: 649 Bytes
1e7a182 | 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 | from app.services.auth import hash_password
from app.db.session import SessionLocal
from app.db.models import Admin
def main():
db = SessionLocal()
try:
email = input("Email: ").strip()
password = input("Password: ").strip()
admin = db.query(Admin).filter(Admin.email == email).first()
if admin:
admin.password_hash = hash_password(password)
else:
admin = Admin(email=email, password_hash=hash_password(password), role="owner")
db.add(admin)
db.commit()
print("Admin saved")
finally:
db.close()
if __name__ == "__main__":
main()
|