Skip to content

Commit

Permalink
Merge pull request #4565 from GSA-TTS/main
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm authored Dec 25, 2024
2 parents 90eec51 + 98fecea commit 6b5c08d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/users/management/commands/create_staffusers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ def handle(self, *args, **kwargs):
).save()

# attempt to update the user.
try:
user = User.objects.get(email=email, is_staff=True)
user = User.objects.filter(email=email, is_staff=True)

if user.exists():
user = user.first()
user.groups.clear()
match role:
case "readonly":
Expand All @@ -106,8 +107,7 @@ def handle(self, *args, **kwargs):
user.save()
logger.info(f"Synced {email} to a StaffUser role.")

# for whatever reason, this failed. Revert staffuser creation.
except User.DoesNotExist:
else:
transaction.set_rollback(True)
logger.warning(
f"StaffUser not created for {email}, they have not logged in yet."
Expand Down

0 comments on commit 6b5c08d

Please sign in to comment.