mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Do not try to create a new admin user if one already exists with that name
This commit is contained in:
parent
f4e3abd44e
commit
20fa72e36f
@ -190,7 +190,8 @@ class InvenTreeConfig(AppConfig):
|
|||||||
user = get_user_model()
|
user = get_user_model()
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
new_user = user.objects.create_superuser(add_user, add_email, add_password)
|
if not user.objects.filter(username=add_user).exists():
|
||||||
|
new_user = user.objects.create_superuser(add_user, add_email, add_password)
|
||||||
logger.info(f'User {str(new_user)} was created!')
|
logger.info(f'User {str(new_user)} was created!')
|
||||||
except IntegrityError as _e:
|
except IntegrityError as _e:
|
||||||
logger.warning(f'The user "{add_user}" could not be created due to the following error:\n{str(_e)}')
|
logger.warning(f'The user "{add_user}" could not be created due to the following error:\n{str(_e)}')
|
||||||
|
Loading…
Reference in New Issue
Block a user