12 lines
493 B
Python
12 lines
493 B
Python
|
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))
|