From ea316627beaccb8c7de16b2347302690dc227d0b Mon Sep 17 00:00:00 2001 From: Jascha Urbach Date: Sun, 11 Dec 2022 21:35:20 +0100 Subject: [PATCH] Manual email confirm (#2492) * manual approve email via bw-dev/manage.py ./bw-dev confirm_email USER (venv) python manage.py confirm_email USER * add "confirm_email" and "remove_2fa" to autocompletion * OK, sometimes I feel fooled by this. The lione was not LONG ENOUGH. * Change deactivate reason to None * Whyever this works now Python in my system is a wondermachine. --- bookwyrm/management/commands/confirm_email.py | 19 +++++++++++++++++++ bw-dev | 4 ++++ complete_bwdev.fish | 4 ++++ complete_bwdev.sh | 2 ++ complete_bwdev.zsh | 2 ++ 5 files changed, 31 insertions(+) create mode 100644 bookwyrm/management/commands/confirm_email.py diff --git a/bookwyrm/management/commands/confirm_email.py b/bookwyrm/management/commands/confirm_email.py new file mode 100644 index 000000000..450da7eec --- /dev/null +++ b/bookwyrm/management/commands/confirm_email.py @@ -0,0 +1,19 @@ +""" manually confirm e-mail of user """ +from django.core.management.base import BaseCommand + +from bookwyrm import models + + +class Command(BaseCommand): + """command-line options""" + + help = "Manually confirm email for 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.reactivate() + self.stdout.write(self.style.SUCCESS("User's email is now confirmed.")) diff --git a/bw-dev b/bw-dev index eecb405fb..ef5dec813 100755 --- a/bw-dev +++ b/bw-dev @@ -265,6 +265,9 @@ case "$CMD" in remove_2fa) runweb python manage.py remove_2fa "$@" ;; + confirm_email) + runweb python manage.py confirm_email "$@" + ;; *) set +x # No need to echo echo echo "Unrecognised command. Try:" @@ -302,5 +305,6 @@ case "$CMD" in echo " set_cors_to_s3 [cors file]" echo " runweb [command]" echo " remove_2fa" + echo " confirm_email" ;; esac diff --git a/complete_bwdev.fish b/complete_bwdev.fish index c86b7e7d3..e680ede43 100644 --- a/complete_bwdev.fish +++ b/complete_bwdev.fish @@ -35,6 +35,8 @@ copy_media_to_s3 \ set_cors_to_s3 \ setup \ admin_code \ +remove_2fa \ +confirm_email \ runweb function __bw_complete -a cmds cmd desc @@ -74,6 +76,8 @@ __bw_complete "$commands" "sync_media_to_s3" "run the `s3 sync` command t __bw_complete "$commands" "set_cors_to_s3" "push a CORS configuration defined in .json to s3" __bw_complete "$commands" "setup" "perform first-time setup" __bw_complete "$commands" "admin_code" "get the admin code" +__bw_complete "$commands" "remove_2fa" "remove 2FA from user" +__bw_complete "$commands" "confirm_email" "manually confirm email of user and set active" __bw_complete "$commands" "runweb" "run a command on the web container" diff --git a/complete_bwdev.sh b/complete_bwdev.sh index 141c8e169..7976b2126 100644 --- a/complete_bwdev.sh +++ b/complete_bwdev.sh @@ -32,4 +32,6 @@ copy_media_to_s3 set_cors_to_s3 setup admin_code +remove_2fa +confirm_email runweb" -o bashdefault -o default bw-dev diff --git a/complete_bwdev.zsh b/complete_bwdev.zsh index 0edc5612c..e9c8028c1 100644 --- a/complete_bwdev.zsh +++ b/complete_bwdev.zsh @@ -34,4 +34,6 @@ copy_media_to_s3 set_cors_to_s3 setup admin_code +remove_2fa +confirm_email runweb" -o bashdefault -o default bw-dev