1
0
Fork 0

Remove TFA from user

added bookwyrm/management/remove_2fa.py

changed bw-dev
This commit is contained in:
Jascha Ezra Urbach 2022-11-15 23:20:21 +01:00
parent f0b73c18c1
commit cd57537854
No known key found for this signature in database
GPG key ID: A43A844B114F9B08
2 changed files with 24 additions and 0 deletions

View file

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