Skip to content

Commit 2ff2e1b

Browse files
committed
User email verification
- Mark all existing users verified - Mark emails verified on a PW reset/invite
1 parent 91cab58 commit 2ff2e1b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

adserver/auth/apps.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
from django.apps import AppConfig
44

55

6+
def pw_reset_callback(sender, request, user, **kwargs):
7+
"""Mark the email verified after a PW reset (includes invite)"""
8+
for email in user.emailaddress_set.filter(email=user.email):
9+
email.set_verified()
10+
11+
612
class AdServerAuthConfig(AppConfig):
713
name = "adserver.auth"
814
label = "adserver_auth"
915
verbose_name = "Ad Server Auth"
16+
17+
def ready(self):
18+
from allauth.account.signals import password_reset # noqa
19+
20+
password_reset.connect(pw_reset_callback)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from django.db import migrations
2+
from django.contrib.auth import get_user_model
3+
4+
5+
def forwards(apps, schema_editor):
6+
"""Mark all existing users verified."""
7+
User = get_user_model()
8+
9+
for user in User.objects.all():
10+
for email in user.emailaddress_set.filter(email=user.email):
11+
email.set_verified()
12+
13+
14+
class Migration(migrations.Migration):
15+
16+
dependencies = [
17+
('adserver_auth', '0009_user_advertiser_publisher_roles'),
18+
]
19+
20+
operations = [
21+
migrations.RunPython(forwards, reverse_code=migrations.RunPython.noop)
22+
]

0 commit comments

Comments
 (0)