Add user creation script

This commit is contained in:
Jimmy 2022-01-16 07:09:23 +00:00
parent bd6afffd77
commit 02097426ba
1 changed files with 18 additions and 0 deletions

18
app/useradd.py Normal file
View File

@ -0,0 +1,18 @@
from distutils.fancy_getopt import fancy_getopt
from site import USER_BASE
from passlib.context import CryptContext
from json import load, dump
from sys import argv
with open("app/users.json", 'r+') as f:
fake_users_db = load(f)
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
fake_users_db[argv[1]] = {"username": argv[1], "hashed_password": pwd_context.hash(argv[2]),
"disabled": False, "servers": argv[3:]}
f.seek(0)
dump(fake_users_db, f, indent=2)
print(fake_users_db)