Repository navigation
SignUp - fix signup 500 errors, block banned users, add account tests - #2611
Conversation
7c6348d to
979113d
Compare
a294b86 to
0f06b5b
Compare
0f06b5b to
a81ce80
Compare
a81ce80 to
9d20c3b
Compare
9d20c3b to
f171b5d
Compare
|
Some feedback here: The email-lowercasing script can crash halfway. |
Nice catch. We can use the code below to catch the ones that cannot be converted and decide about theme later. from django.db import IntegrityError, transaction
from profiles.models import User
failed_users = []
for user in User.objects.exclude(email__isnull=True):
if user.email != user.email.lower():
original_email = user.email
user.email = user.email.lower()
try:
# Each save is undone on its own if it fails, so the loop keeps going
with transaction.atomic():
user.save()
except IntegrityError:
# Another account already has this email in lowercase, e.g. "[email protected]" when "[email protected]" exists
failed_users.append((user.id, user.username, original_email))
for user_id, username, email in failed_users:
print(f"Could not convert id={user_id} username={username} email={email}")We can still use this code below to get the count before and after to see how many are converted and how many are left User.objects.exclude(email__isnull=True).filter(email__regex=r'[A-Z]').count() |
a69e709 to
39827dd
Compare
39827dd to
70e24f0
Compare
Description
Upgrade instructions: convert existing email addresses
500 error in signup was caused by entering the same email already registered but with some capital letters. For example instead of writing
[email protected]a user enters[email protected]or[email protected]. Now that signup converts email to lowercase, we need to run the following code once this is deployed to convert all emails to lowercase.Activate django shell plus
get count of users with capitals in email
convert emails to lowercase
get count of users agint to verify
Issues this PR resolves
Checklist