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.
This commit is contained in:
Jascha Urbach 2022-12-11 21:35:20 +01:00 committed by GitHub
parent a9846e7805
commit ea316627be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 0 deletions

View file

@ -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."))

4
bw-dev
View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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