Don't allow invalid account reactivation

This commit is contained in:
Mouse Reeve 2023-06-21 15:46:50 -07:00
parent 65e3a31354
commit 11f1a4662e
2 changed files with 5 additions and 1 deletions

View file

@ -394,6 +394,8 @@ class User(OrderedCollectionPageMixin, AbstractUser):
def reactivate(self):
"""Now you want to come back, huh?"""
# pylint: disable=attribute-defined-outside-init
if not user.allow_reactivation:
return
self.is_active = True
self.deactivation_reason = None
self.allow_reactivation = False

View file

@ -105,7 +105,9 @@ class ConfirmEmailCode(View):
# look up the user associated with this code
try:
user = models.User.objects.get(confirmation_code=code)
user = models.User.objects.get(
confirmation_code=code, deactivation_reason="pending"
)
except models.User.DoesNotExist:
return TemplateResponse(
request, "confirm_email/confirm_email.html", {"valid": False}