Merge pull request #1854 from bookwyrm-social/pending-users
Activate users in pending state when site registration mode changes
This commit is contained in:
@ -93,3 +93,48 @@ class SiteModels(TestCase):
|
||||
token = models.PasswordReset.objects.create(user=self.local_user, code="hello")
|
||||
self.assertTrue(token.valid())
|
||||
self.assertEqual(token.link, f"https://{settings.DOMAIN}/password-reset/hello")
|
||||
|
||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||
@patch("bookwyrm.suggested_users.remove_user_task.delay")
|
||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||
@patch("bookwyrm.lists_stream.populate_lists_task.delay")
|
||||
def test_change_confirmation_scheme(self, *_):
|
||||
"""Switch from requiring email confirmation to not"""
|
||||
site = models.SiteSettings.objects.create(
|
||||
id=1, name="Fish Town", require_confirm_email=True
|
||||
)
|
||||
banned_user = models.User.objects.create_user(
|
||||
"rat@local.com",
|
||||
"rat@rat.com",
|
||||
"ratword",
|
||||
local=True,
|
||||
localname="rat",
|
||||
remote_id="https://example.com/users/rat",
|
||||
confirmation_code="HELLO",
|
||||
)
|
||||
banned_user.is_active = False
|
||||
banned_user.deactivation_reason = "banned"
|
||||
banned_user.save(broadcast=False)
|
||||
|
||||
pending_user = models.User.objects.create_user(
|
||||
"nutria@local.com",
|
||||
"nutria@nutria.com",
|
||||
"nutriaword",
|
||||
local=True,
|
||||
localname="nutria",
|
||||
remote_id="https://example.com/users/nutria",
|
||||
confirmation_code="HELLO",
|
||||
)
|
||||
pending_user.is_active = False
|
||||
pending_user.deactivation_reason = "pending"
|
||||
pending_user.save(broadcast=False)
|
||||
site.require_confirm_email = False
|
||||
site.save()
|
||||
|
||||
pending_user.refresh_from_db()
|
||||
self.assertTrue(pending_user.is_active)
|
||||
self.assertIsNone(pending_user.deactivation_reason)
|
||||
|
||||
banned_user.refresh_from_db()
|
||||
self.assertFalse(banned_user.is_active)
|
||||
self.assertIsNotNone(banned_user.deactivation_reason)
|
||||
|
Reference in New Issue
Block a user