feat: set first user to admin by default

This commit is contained in:
Timothy J. Baek 2023-11-19 00:41:29 -08:00
parent 07d2c9871f
commit 83ff1d77ea
8 changed files with 28 additions and 25 deletions

View file

@ -86,8 +86,9 @@ async def signin(form_data: SigninForm):
async def signup(form_data: SignupForm):
if not Users.get_user_by_email(form_data.email.lower()):
try:
role = "admin" if Users.get_num_users() == 0 else "pending"
hashed = get_password_hash(form_data.password)
user = Auths.insert_new_auth(form_data.email, hashed, form_data.name)
user = Auths.insert_new_auth(form_data.email, hashed, form_data.name, role)
if user:
token = create_token(data={"email": user.email})