From cd575378541ce48131a4c81c8e259e8fd528d628 Mon Sep 17 00:00:00 2001 From: Jascha Urbach Date: Tue, 15 Nov 2022 23:20:21 +0100 Subject: [PATCH 1/2] Remove TFA from user added bookwyrm/management/remove_2fa.py changed bw-dev --- bookwyrm/management/commands/remove_2fa.py | 18 ++++++++++++++++++ bw-dev | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 bookwyrm/management/commands/remove_2fa.py diff --git a/bookwyrm/management/commands/remove_2fa.py b/bookwyrm/management/commands/remove_2fa.py new file mode 100644 index 000000000..fa648f79c --- /dev/null +++ b/bookwyrm/management/commands/remove_2fa.py @@ -0,0 +1,18 @@ +"""deactivate two factor auth""" + +from django.core.management.base import BaseCommand, CommandError +from bookwyrm import models + +class Command(BaseCommand): + """command-line options""" + help = "Remove Two Factor Authorisation from user" + + def add_arguments(self, parser): + parser.add_argument("username") + + def handle(self, *args, **options): + name = (options["username"]) + user = models.User.objects.get(localname=name) + user.two_factor_auth = False + user.save(broadcast=False, update_fields=["two_factor_auth"]) + self.stdout.write(self.style.SUCCESS("Two Factor Authorisation was removed from user")) \ No newline at end of file diff --git a/bw-dev b/bw-dev index a8f638803..7033f16b3 100755 --- a/bw-dev +++ b/bw-dev @@ -63,6 +63,8 @@ function awscommand { amazon/aws-cli $2 } + + CMD=$1 if [ -n "$CMD" ]; then shift @@ -255,6 +257,9 @@ case "$CMD" in runweb) runweb "$@" ;; + remove_2fa) + runweb python manage.py remove_2fa "$@" + ;; *) set +x # No need to echo echo echo "Unrecognised command. Try:" @@ -290,5 +295,6 @@ case "$CMD" in echo " sync_media_to_s3" echo " set_cors_to_s3 [cors file]" echo " runweb [command]" + echo " remove_2fa" ;; esac From 8a99482a2fba0b58791b2f212ba61780eeefa439 Mon Sep 17 00:00:00 2001 From: Jascha Urbach Date: Tue, 15 Nov 2022 23:32:24 +0100 Subject: [PATCH 2/2] correct linter errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ./bw-dev black reformatted bookwyrm/management/commands/remove_2fa.py All done! ✨ 🍰 ✨ 1 file reformatted, 544 files left unchanged. --- bookwyrm/management/commands/remove_2fa.py | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/bookwyrm/management/commands/remove_2fa.py b/bookwyrm/management/commands/remove_2fa.py index fa648f79c..1c9d5f71a 100644 --- a/bookwyrm/management/commands/remove_2fa.py +++ b/bookwyrm/management/commands/remove_2fa.py @@ -3,16 +3,20 @@ from django.core.management.base import BaseCommand, CommandError from bookwyrm import models + class Command(BaseCommand): - """command-line options""" - help = "Remove Two Factor Authorisation from user" + """command-line options""" - def add_arguments(self, parser): - parser.add_argument("username") + help = "Remove Two Factor Authorisation from user" - def handle(self, *args, **options): - name = (options["username"]) - user = models.User.objects.get(localname=name) - user.two_factor_auth = False - user.save(broadcast=False, update_fields=["two_factor_auth"]) - self.stdout.write(self.style.SUCCESS("Two Factor Authorisation was removed from user")) \ No newline at end of file + def add_arguments(self, parser): + parser.add_argument("username") + + def handle(self, *args, **options): + name = options["username"] + user = models.User.objects.get(localname=name) + user.two_factor_auth = False + user.save(broadcast=False, update_fields=["two_factor_auth"]) + self.stdout.write( + self.style.SUCCESS("Two Factor Authorisation was removed from user") + )