22 lines
628 B
Python
22 lines
628 B
Python
"""Create a human panel administrator without ever printing the password."""
|
|
|
|
import getpass
|
|
|
|
from central.app.db import SessionLocal
|
|
from central.app.human_auth import create_admin
|
|
|
|
|
|
def main():
|
|
username = input("Admin username: ").strip()
|
|
password = getpass.getpass("Admin password (12+ chars): ")
|
|
confirmation = getpass.getpass("Confirm password: ")
|
|
if password != confirmation:
|
|
raise SystemExit("passwords do not match")
|
|
with SessionLocal() as session:
|
|
admin = create_admin(session, username, password)
|
|
print(f"created admin {admin.username}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|