studyhub-app / studyhub /app /make_user.py
parhamkhoshsolat's picture
StudyHub web — custom Docker frontend (FastAPI + SPA)
8db761b verified
Raw
History Blame Contribute Delete
511 Bytes
from __future__ import annotations
import getpass
import sys
from .auth import hash_password
def main() -> None:
if len(sys.argv) != 3 or sys.argv[2] not in ("reader", "admin"):
print("usage: python -m studyhub.app.make_user <username> <reader|admin>")
sys.exit(1)
username, role = sys.argv[1], sys.argv[2]
pw = getpass.getpass("password: ")
salt_hex, hash_hex = hash_password(pw)
print(f"{username}:{role}:{salt_hex}${hash_hex}")
if __name__ == "__main__":
main()