From 50a42dc0a22461c153a1b53d613c2af85dfba89b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 11 Dec 2022 11:43:30 -0800 Subject: [PATCH] Use user.reactivate when a user confirms their email address This is cleaner and easier to maintain. --- bookwyrm/models/user.py | 5 ++++- bookwyrm/views/landing/register.py | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index e48d86572..c885902f9 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -390,7 +390,10 @@ class User(OrderedCollectionPageMixin, AbstractUser): self.is_active = True self.deactivation_reason = None self.allow_reactivation = False - super().save(broadcast=False) + super().save( + broadcast=False, + update_fields=["deactivation_reason", "is_active", "allow_reactivation"], + ) @property def local_path(self): diff --git a/bookwyrm/views/landing/register.py b/bookwyrm/views/landing/register.py index c5fd17424..ff199b57e 100644 --- a/bookwyrm/views/landing/register.py +++ b/bookwyrm/views/landing/register.py @@ -105,9 +105,7 @@ class ConfirmEmailCode(View): request, "confirm_email/confirm_email.html", {"valid": False} ) # update the user - user.is_active = True - user.deactivation_reason = None - user.save(broadcast=False, update_fields=["is_active", "deactivation_reason"]) + user.reactivate() # direct the user to log in return redirect("login", confirmed="confirmed")