2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

Merge pull request #2972 from SchrodingersGat/user-create-auto-fix

Do not try to create a new admin user if one already exists
This commit is contained in:
Oliver 2022-05-11 23:29:16 +10:00 committed by GitHub
commit 2652c75bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,6 +190,9 @@ class InvenTreeConfig(AppConfig):
user = get_user_model()
try:
with transaction.atomic():
if user.objects.filter(username=add_user).exists():
logger.info(f"User {add_user} already exists - skipping creation")
else:
new_user = user.objects.create_superuser(add_user, add_email, add_password)
logger.info(f'User {str(new_user)} was created!')
except IntegrityError as _e: