12 lines
493 B
Python
Raw Normal View History

2023-10-13 21:44:30 +02:00
from ..models import users
from ..dependencies import database
from passlib.context import CryptContext
def add(username="", password="", roles="User", disabled=False):
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
user = users.User(username=username, password=pwd_context.hash(password), roles=roles, disabled=disabled)
user_repository = users.UserRepository(database=database.database)
user_repository.save(user)
print("{O} added".format(username))