Skip to content

Commit

Permalink
feat: add handling for edge case where non-superuser exists
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran committed Jan 11, 2024
1 parent dec4de7 commit 0273f10
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion benefits/superuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
user = User.objects.filter(username=username)

if user.exists():
logger.debug("Skipping superuser creation since it already exists")
if user.first().is_superuser:
logger.debug("Skipping superuser creation since it already exists")
else:
raise RuntimeError("A user already exists with DJANGO_SUPERUSER_NAME as the username")
else:
email = os.environ.get("DJANGO_SUPERUSER_EMAIL")
password = os.environ.get("DJANGO_SUPERUSER_PASSWORD")
Expand Down

0 comments on commit 0273f10

Please sign in to comment.