Skip to content

Commit

Permalink
core: fix change_user_type always requiring usernames (goauthentik#11177
Browse files Browse the repository at this point in the history
)

Signed-off-by: Jens Langhammer <[email protected]>
  • Loading branch information
BeryJu authored Sep 3, 2024
1 parent 4d51671 commit 5f261be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions authentik/core/management/commands/change_user_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class Command(TenantCommand):

def add_arguments(self, parser):
parser.add_argument("--type", type=str, required=True)
parser.add_argument("--all", action="store_true")
parser.add_argument("usernames", nargs="+", type=str)
parser.add_argument("--all", action="store_true", default=False)
parser.add_argument("usernames", nargs="*", type=str)

def handle_per_tenant(self, **options):
print(options)
new_type = UserTypes(options["type"])
qs = (
User.objects.exclude_anonymous()
Expand All @@ -22,6 +23,9 @@ def handle_per_tenant(self, **options):
if options["usernames"] and options["all"]:
self.stderr.write("--all and usernames specified, only one can be specified")
return
if not options["usernames"] and not options["all"]:
self.stderr.write("--all or usernames must be specified")
return
if options["usernames"] and not options["all"]:
qs = qs.filter(username__in=options["usernames"])
updated = qs.update(type=new_type)
Expand Down

0 comments on commit 5f261be

Please sign in to comment.