Spaces:
Running
Running
File size: 710 Bytes
79dca2e | 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 | """Create or update the initial admin account."""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from server.db import init_db, create_admin, get_admin
from server.auth import hash_password
def main():
init_db()
username = os.getenv("ADMIN_USER", "admin")
password = os.getenv("ADMIN_PASS", "admin123")
if get_admin(username):
print(f"Admin '{username}' already exists, skipping.")
return
pw_hash = hash_password(password)
if create_admin(username, pw_hash):
print(f"Admin '{username}' created successfully.")
else:
print(f"Failed to create admin '{username}'.")
if __name__ == "__main__":
main()
|